Selaa lähdekoodia

codec: fix suggestions raised by golint -min_confidence 0.9, misspellings and ineffassign

Ugorji Nwoke 8 vuotta sitten
vanhempi
commit
5a66da2e74

+ 4 - 4
codec/0doc.go

@@ -2,8 +2,9 @@
 // Use of this source code is governed by a MIT license found in the LICENSE file.
 // Use of this source code is governed by a MIT license found in the LICENSE file.
 
 
 /*
 /*
-High Performance, Feature-Rich Idiomatic Go 1.4+ codec/encoding library for
-binc, msgpack, cbor, json
+Package codec provides a
+High Performance, Feature-Rich Idiomatic Go 1.4+ codec/encoding library
+for binc, msgpack, cbor, json.
 
 
 Supported Serialization formats are:
 Supported Serialization formats are:
 
 
@@ -109,7 +110,7 @@ This symmetry is important to reduce chances of issues happening because the
 encoding and decoding sides are out of sync e.g. decoded via very specific
 encoding and decoding sides are out of sync e.g. decoded via very specific
 encoding.TextUnmarshaler but encoded via kind-specific generalized mode.
 encoding.TextUnmarshaler but encoded via kind-specific generalized mode.
 
 
-Consequently, if a type only defines one-half of the symetry
+Consequently, if a type only defines one-half of the symmetry
 (e.g. it implements UnmarshalJSON() but not MarshalJSON() ),
 (e.g. it implements UnmarshalJSON() but not MarshalJSON() ),
 then that type doesn't satisfy the check and we will continue walking down the
 then that type doesn't satisfy the check and we will continue walking down the
 decision tree.
 decision tree.
@@ -203,4 +204,3 @@ Please see http://github.com/ugorji/go-codec-bench .
 
 
 */
 */
 package codec
 package codec
-

+ 1 - 1
codec/README.md

@@ -107,7 +107,7 @@ This symmetry is important to reduce chances of issues happening because the
 encoding and decoding sides are out of sync e.g. decoded via very specific
 encoding and decoding sides are out of sync e.g. decoded via very specific
 encoding.TextUnmarshaler but encoded via kind-specific generalized mode.
 encoding.TextUnmarshaler but encoded via kind-specific generalized mode.
 
 
-Consequently, if a type only defines one-half of the symetry
+Consequently, if a type only defines one-half of the symmetry
 (e.g. it implements UnmarshalJSON() but not MarshalJSON() ),
 (e.g. it implements UnmarshalJSON() but not MarshalJSON() ),
 then that type doesn't satisfy the check and we will continue walking down the
 then that type doesn't satisfy the check and we will continue walking down the
 decision tree.
 decision tree.

+ 13 - 9
codec/binc.go

@@ -208,7 +208,7 @@ func (e *bincEncDriver) EncodeString(c charEncoding, v string) {
 
 
 func (e *bincEncDriver) EncodeSymbol(v string) {
 func (e *bincEncDriver) EncodeSymbol(v string) {
 	// if WriteSymbolsNoRefs {
 	// if WriteSymbolsNoRefs {
-	// 	e.encodeString(c_UTF8, v)
+	// 	e.encodeString(cUTF8, v)
 	// 	return
 	// 	return
 	// }
 	// }
 
 
@@ -218,10 +218,10 @@ func (e *bincEncDriver) EncodeSymbol(v string) {
 
 
 	l := len(v)
 	l := len(v)
 	if l == 0 {
 	if l == 0 {
-		e.encBytesLen(c_UTF8, 0)
+		e.encBytesLen(cUTF8, 0)
 		return
 		return
 	} else if l == 1 {
 	} else if l == 1 {
-		e.encBytesLen(c_UTF8, 1)
+		e.encBytesLen(cUTF8, 1)
 		e.w.writen1(v[0])
 		e.w.writen1(v[0])
 		return
 		return
 	}
 	}
@@ -280,7 +280,7 @@ func (e *bincEncDriver) EncodeStringBytes(c charEncoding, v []byte) {
 
 
 func (e *bincEncDriver) encBytesLen(c charEncoding, length uint64) {
 func (e *bincEncDriver) encBytesLen(c charEncoding, length uint64) {
 	//TODO: support bincUnicodeOther (for now, just use string or bytearray)
 	//TODO: support bincUnicodeOther (for now, just use string or bytearray)
-	if c == c_RAW {
+	if c == cRAW {
 		e.encLen(bincVdByteArray<<4, length)
 		e.encLen(bincVdByteArray<<4, length)
 	} else {
 	} else {
 		e.encLen(bincVdString<<4, length)
 		e.encLen(bincVdString<<4, length)
@@ -365,9 +365,10 @@ func (d *bincDecDriver) ContainerType() (vt valueType) {
 		return valueTypeArray
 		return valueTypeArray
 	} else if d.vd == bincVdMap {
 	} else if d.vd == bincVdMap {
 		return valueTypeMap
 		return valueTypeMap
-	} else {
-		// d.d.errorf("isContainerType: unsupported parameter: %v", vt)
 	}
 	}
+	// else {
+	// d.d.errorf("isContainerType: unsupported parameter: %v", vt)
+	// }
 	return valueTypeUnset
 	return valueTypeUnset
 }
 }
 
 
@@ -399,7 +400,7 @@ func (d *bincDecDriver) DecodeBuiltin(rt uintptr, v interface{}) {
 		if err != nil {
 		if err != nil {
 			panic(err)
 			panic(err)
 		}
 		}
-		var vt *time.Time = v.(*time.Time)
+		var vt = v.(*time.Time)
 		*vt = tt
 		*vt = tt
 		d.bdRead = false
 		d.bdRead = false
 		return
 		return
@@ -637,7 +638,7 @@ func (d *bincDecDriver) decStringAndBytes(bs []byte, withString, zerocopy bool)
 		d.bdRead = false
 		d.bdRead = false
 		return
 		return
 	}
 	}
-	var slen int = -1
+	var slen = -1
 	// var ok bool
 	// var ok bool
 	switch d.vd {
 	switch d.vd {
 	case bincVdString, bincVdByteArray:
 	case bincVdString, bincVdByteArray:
@@ -910,6 +911,7 @@ type BincHandle struct {
 	noElemSeparators
 	noElemSeparators
 }
 }
 
 
+// SetBytesExt sets an extension
 func (h *BincHandle) SetBytesExt(rt reflect.Type, tag uint64, ext BytesExt) (err error) {
 func (h *BincHandle) SetBytesExt(rt reflect.Type, tag uint64, ext BytesExt) (err error) {
 	return h.SetExt(rt, tag, &setExtWrapper{b: ext})
 	return h.SetExt(rt, tag, &setExtWrapper{b: ext})
 }
 }
@@ -922,7 +924,9 @@ func (h *BincHandle) newDecDriver(d *Decoder) decDriver {
 	return &bincDecDriver{d: d, h: h, r: d.r, br: d.bytes}
 	return &bincDecDriver{d: d, h: h, r: d.r, br: d.bytes}
 }
 }
 
 
-func (_ *BincHandle) IsBuiltinType(rt uintptr) bool {
+// IsBuiltinType returns true for time.Time, else false.
+// only time.Time is builtin.
+func (h *BincHandle) IsBuiltinType(rt uintptr) bool {
 	return rt == timeTypId
 	return rt == timeTypId
 }
 }
 
 

+ 7 - 3
codec/cbor.go

@@ -38,6 +38,8 @@ const (
 	cborBdBreak                 = 0xff
 	cborBdBreak                 = 0xff
 )
 )
 
 
+// These define some in-stream descriptors for
+// manual encoding e.g. when doing explicit indefinite-length
 const (
 const (
 	CborStreamBytes  byte = 0x5f
 	CborStreamBytes  byte = 0x5f
 	CborStreamString      = 0x7f
 	CborStreamString      = 0x7f
@@ -181,7 +183,7 @@ func (e *cborEncDriver) EncodeString(c charEncoding, v string) {
 }
 }
 
 
 func (e *cborEncDriver) EncodeStringBytes(c charEncoding, v []byte) {
 func (e *cborEncDriver) EncodeStringBytes(c charEncoding, v []byte) {
-	if c == c_RAW {
+	if c == cRAW {
 		e.encStringBytesS(cborBaseBytes, stringView(v))
 		e.encStringBytesS(cborBaseBytes, stringView(v))
 	} else {
 	} else {
 		e.encStringBytesS(cborBaseString, stringView(v))
 		e.encStringBytesS(cborBaseString, stringView(v))
@@ -261,9 +263,10 @@ func (d *cborDecDriver) ContainerType() (vt valueType) {
 		return valueTypeArray
 		return valueTypeArray
 	} else if d.bd == cborBdIndefiniteMap || (d.bd >= cborBaseMap && d.bd < cborBaseTag) {
 	} else if d.bd == cborBdIndefiniteMap || (d.bd >= cborBaseMap && d.bd < cborBaseTag) {
 		return valueTypeMap
 		return valueTypeMap
-	} else {
-		// d.d.errorf("isContainerType: unsupported parameter: %v", vt)
 	}
 	}
+	// else {
+	// d.d.errorf("isContainerType: unsupported parameter: %v", vt)
+	// }
 	return valueTypeUnset
 	return valueTypeUnset
 }
 }
 
 
@@ -622,6 +625,7 @@ type CborHandle struct {
 	IndefiniteLength bool
 	IndefiniteLength bool
 }
 }
 
 
+// SetInterfaceExt sets an extension
 func (h *CborHandle) SetInterfaceExt(rt reflect.Type, tag uint64, ext InterfaceExt) (err error) {
 func (h *CborHandle) SetInterfaceExt(rt reflect.Type, tag uint64, ext InterfaceExt) (err error) {
 	return h.SetExt(rt, tag, &setExtWrapper{i: ext})
 	return h.SetExt(rt, tag, &setExtWrapper{i: ext})
 }
 }

+ 4 - 4
codec/codec_test.go

@@ -40,11 +40,11 @@ type testCustomStringT string
 // make this a mapbyslice
 // make this a mapbyslice
 type testMbsT []interface{}
 type testMbsT []interface{}
 
 
-func (_ testMbsT) MapBySlice() {}
+func (testMbsT) MapBySlice() {}
 
 
 type testMbsCustStrT []testCustomStringT
 type testMbsCustStrT []testCustomStringT
 
 
-func (_ testMbsCustStrT) MapBySlice() {}
+func (testMbsCustStrT) MapBySlice() {}
 
 
 type testVerifyFlag uint8
 type testVerifyFlag uint8
 
 
@@ -716,7 +716,7 @@ func testCodecMiscOne(t *testing.T, h Handle) {
 	// 	logT(t, "------- Expecting error because we cannot unmarshal to int32 nil ptr")
 	// 	logT(t, "------- Expecting error because we cannot unmarshal to int32 nil ptr")
 	// 	failT(t)
 	// 	failT(t)
 	// }
 	// }
-	var i2 int32 = 0
+	var i2 int32
 	testUnmarshalErr(&i2, b, h, t, "int32-ptr")
 	testUnmarshalErr(&i2, b, h, t, "int32-ptr")
 	if i2 != int32(32) {
 	if i2 != int32(32) {
 		logT(t, "------- didn't unmarshal to 32: Received: %d", i2)
 		logT(t, "------- didn't unmarshal to 32: Received: %d", i2)
@@ -1004,7 +1004,7 @@ func testCodecRpcOne(t *testing.T, rr Rpc, h Handle, doRequest bool, exitSleepMs
 	// opts.MapType = mapStrIntfTyp
 	// opts.MapType = mapStrIntfTyp
 	// opts.RawToString = false
 	// opts.RawToString = false
 	serverExitChan := make(chan bool, 1)
 	serverExitChan := make(chan bool, 1)
-	var serverExitFlag uint64 = 0
+	var serverExitFlag uint64
 	serverFn := func() {
 	serverFn := func() {
 		for {
 		for {
 			conn1, err1 := ln.Accept()
 			conn1, err1 := ln.Accept()

+ 29 - 27
codec/decode.go

@@ -20,12 +20,12 @@ const (
 )
 )
 
 
 var (
 var (
-	onlyMapOrArrayCanDecodeIntoStructErr = errors.New("only encoded map or array can be decoded into a struct")
-	cannotDecodeIntoNilErr               = errors.New("cannot decode into nil")
+	errOnlyMapOrArrayCanDecodeIntoStruct = errors.New("only encoded map or array can be decoded into a struct")
+	errCannotDecodeIntoNil               = errors.New("cannot decode into nil")
 
 
-	decUnreadByteNothingToReadErr   = errors.New("cannot unread - nothing has been read")
-	decUnreadByteLastByteNotReadErr = errors.New("cannot unread - last byte has not been read")
-	decUnreadByteUnknownErr         = errors.New("cannot unread - reason unknown")
+	errDecUnreadByteNothingToRead   = errors.New("cannot unread - nothing has been read")
+	errDecUnreadByteLastByteNotRead = errors.New("cannot unread - last byte has not been read")
+	errDecUnreadByteUnknown         = errors.New("cannot unread - reason unknown")
 )
 )
 
 
 // decReader abstracts the reading source, allowing implementations that can
 // decReader abstracts the reading source, allowing implementations that can
@@ -108,22 +108,20 @@ type decDriver interface {
 	uncacheRead()
 	uncacheRead()
 }
 }
 
 
-// type decNoSeparator struct {}
-// func (_ decNoSeparator) ReadEnd() {}
-
 type decDriverNoopContainerReader struct{}
 type decDriverNoopContainerReader struct{}
 
 
-func (_ decDriverNoopContainerReader) ReadArrayStart() (v int) { return }
-func (_ decDriverNoopContainerReader) ReadArrayElem()          {}
-func (_ decDriverNoopContainerReader) ReadArrayEnd()           {}
-func (_ decDriverNoopContainerReader) ReadMapStart() (v int)   { return }
-func (_ decDriverNoopContainerReader) ReadMapElemKey()         {}
-func (_ decDriverNoopContainerReader) ReadMapElemValue()       {}
-func (_ decDriverNoopContainerReader) ReadMapEnd()             {}
-func (_ decDriverNoopContainerReader) CheckBreak() (v bool)    { return }
+func (x decDriverNoopContainerReader) ReadArrayStart() (v int) { return }
+func (x decDriverNoopContainerReader) ReadArrayElem()          {}
+func (x decDriverNoopContainerReader) ReadArrayEnd()           {}
+func (x decDriverNoopContainerReader) ReadMapStart() (v int)   { return }
+func (x decDriverNoopContainerReader) ReadMapElemKey()         {}
+func (x decDriverNoopContainerReader) ReadMapElemValue()       {}
+func (x decDriverNoopContainerReader) ReadMapEnd()             {}
+func (x decDriverNoopContainerReader) CheckBreak() (v bool)    { return }
 
 
-// func (_ decNoSeparator) uncacheRead() {}
+// func (x decNoSeparator) uncacheRead() {}
 
 
+// DecodeOptions captures configuration options during decode.
 type DecodeOptions struct {
 type DecodeOptions struct {
 	// MapType specifies type to use during schema-less decoding of a map in the stream.
 	// MapType specifies type to use during schema-less decoding of a map in the stream.
 	// If nil, we use map[interface{}]interface{}
 	// If nil, we use map[interface{}]interface{}
@@ -334,7 +332,7 @@ func (z *bufioDecReader) UnreadByte() (err error) {
 		}
 		}
 		return
 		return
 	}
 	}
-	return decUnreadByteNothingToReadErr
+	return errDecUnreadByteNothingToRead
 }
 }
 
 
 func (z *bufioDecReader) numread() int {
 func (z *bufioDecReader) numread() int {
@@ -602,11 +600,11 @@ func (z *ioDecReader) UnreadByte() (err error) {
 	case 2:
 	case 2:
 		z.ls = 1
 		z.ls = 1
 	case 0:
 	case 0:
-		err = decUnreadByteNothingToReadErr
+		err = errDecUnreadByteNothingToRead
 	case 1:
 	case 1:
-		err = decUnreadByteLastByteNotReadErr
+		err = errDecUnreadByteLastByteNotRead
 	default:
 	default:
-		err = decUnreadByteUnknownErr
+		err = errDecUnreadByteUnknown
 	}
 	}
 	return
 	return
 }
 }
@@ -745,7 +743,7 @@ func (z *ioDecReader) stopTrack() (bs []byte) {
 
 
 // ------------------------------------
 // ------------------------------------
 
 
-var bytesDecReaderCannotUnreadErr = errors.New("cannot unread last byte read")
+var errBytesDecReaderCannotUnread = errors.New("cannot unread last byte read")
 
 
 // bytesDecReader is a decReader that reads off a byte slice with zero copying
 // bytesDecReader is a decReader that reads off a byte slice with zero copying
 type bytesDecReader struct {
 type bytesDecReader struct {
@@ -768,7 +766,7 @@ func (z *bytesDecReader) numread() int {
 
 
 func (z *bytesDecReader) unreadn1() {
 func (z *bytesDecReader) unreadn1() {
 	if z.c == 0 || len(z.b) == 0 {
 	if z.c == 0 || len(z.b) == 0 {
-		panic(bytesDecReaderCannotUnreadErr)
+		panic(errBytesDecReaderCannotUnread)
 	}
 	}
 	z.c--
 	z.c--
 	z.a++
 	z.a++
@@ -1186,7 +1184,7 @@ func (d *Decoder) kStruct(f *codecFnInfo, rv reflect.Value) {
 		}
 		}
 		dd.ReadArrayEnd()
 		dd.ReadArrayEnd()
 	} else {
 	} else {
-		d.error(onlyMapOrArrayCanDecodeIntoStructErr)
+		d.error(errOnlyMapOrArrayCanDecodeIntoStruct)
 		return
 		return
 	}
 	}
 }
 }
@@ -1781,6 +1779,8 @@ func (d *Decoder) resetCommon() {
 	}
 	}
 }
 }
 
 
+// Reset the Decoder with a new Reader to decode from,
+// clearing all state from last run(s).
 func (d *Decoder) Reset(r io.Reader) {
 func (d *Decoder) Reset(r io.Reader) {
 	if d.h.ReaderBufferSize > 0 {
 	if d.h.ReaderBufferSize > 0 {
 		d.bi.buf = make([]byte, 0, d.h.ReaderBufferSize)
 		d.bi.buf = make([]byte, 0, d.h.ReaderBufferSize)
@@ -1795,6 +1795,8 @@ func (d *Decoder) Reset(r io.Reader) {
 	d.resetCommon()
 	d.resetCommon()
 }
 }
 
 
+// ResetBytes resets the Decoder with a new []byte to decode from,
+// clearing all state from last run(s).
 func (d *Decoder) ResetBytes(in []byte) {
 func (d *Decoder) ResetBytes(in []byte) {
 	d.bytes = true
 	d.bytes = true
 	d.rb.reset(in)
 	d.rb.reset(in)
@@ -2002,7 +2004,7 @@ func (d *Decoder) decode(iv interface{}) {
 	// check nil and interfaces explicitly,
 	// check nil and interfaces explicitly,
 	// so that type switches just have a run of constant non-interface types.
 	// so that type switches just have a run of constant non-interface types.
 	if iv == nil {
 	if iv == nil {
-		d.error(cannotDecodeIntoNilErr)
+		d.error(errCannotDecodeIntoNil)
 		return
 		return
 	}
 	}
 	if v, ok := iv.(Selfer); ok {
 	if v, ok := iv.(Selfer); ok {
@@ -2153,7 +2155,7 @@ func (d *Decoder) ensureDecodeable(rv reflect.Value) (rv2 reflect.Value) {
 		return
 		return
 	}
 	}
 	if !rv.IsValid() {
 	if !rv.IsValid() {
-		d.error(cannotDecodeIntoNilErr)
+		d.error(errCannotDecodeIntoNil)
 		return
 		return
 	}
 	}
 	if !rv.CanInterface() {
 	if !rv.CanInterface() {
@@ -2175,7 +2177,7 @@ func (d *Decoder) ensureDecodeable(rv reflect.Value) (rv2 reflect.Value) {
 
 
 // func (d *Decoder) errNotValidPtrValue(rv reflect.Value) {
 // func (d *Decoder) errNotValidPtrValue(rv reflect.Value) {
 // 	if !rv.IsValid() {
 // 	if !rv.IsValid() {
-// 		d.error(cannotDecodeIntoNilErr)
+// 		d.error(errCannotDecodeIntoNil)
 // 		return
 // 		return
 // 	}
 // 	}
 // 	if !rv.CanInterface() {
 // 	if !rv.CanInterface() {

+ 35 - 36
codec/encode.go

@@ -28,10 +28,10 @@ const (
 	// AsSymbolNone means do not encode anything as a symbol.
 	// AsSymbolNone means do not encode anything as a symbol.
 	AsSymbolNone = 1 << iota
 	AsSymbolNone = 1 << iota
 
 
-	// AsSymbolMapStringKeys means encode keys in map[string]XXX as symbols.
+	// AsSymbolMapStringKeysFlag means encode keys in map[string]XXX as symbols.
 	AsSymbolMapStringKeysFlag
 	AsSymbolMapStringKeysFlag
 
 
-	// AsSymbolStructFieldName means encode struct field names as symbols.
+	// AsSymbolStructFieldNameFlag means encode struct field names as symbols.
 	AsSymbolStructFieldNameFlag
 	AsSymbolStructFieldNameFlag
 )
 )
 
 
@@ -84,19 +84,16 @@ type encDriverAsis interface {
 	EncodeAsis(v []byte)
 	EncodeAsis(v []byte)
 }
 }
 
 
-// type encNoSeparator struct{}
-// func (_ encNoSeparator) EncodeEnd() {}
-
 type encDriverNoopContainerWriter struct{}
 type encDriverNoopContainerWriter struct{}
 
 
-func (_ encDriverNoopContainerWriter) WriteArrayStart(length int) {}
-func (_ encDriverNoopContainerWriter) WriteArrayElem()            {}
-func (_ encDriverNoopContainerWriter) WriteArrayEnd()             {}
-func (_ encDriverNoopContainerWriter) WriteMapStart(length int)   {}
-func (_ encDriverNoopContainerWriter) WriteMapElemKey()           {}
-func (_ encDriverNoopContainerWriter) WriteMapElemValue()         {}
-func (_ encDriverNoopContainerWriter) WriteMapEnd()               {}
-func (_ encDriverNoopContainerWriter) atEndOfEncode()             {}
+func (encDriverNoopContainerWriter) WriteArrayStart(length int) {}
+func (encDriverNoopContainerWriter) WriteArrayElem()            {}
+func (encDriverNoopContainerWriter) WriteArrayEnd()             {}
+func (encDriverNoopContainerWriter) WriteMapStart(length int)   {}
+func (encDriverNoopContainerWriter) WriteMapElemKey()           {}
+func (encDriverNoopContainerWriter) WriteMapElemValue()         {}
+func (encDriverNoopContainerWriter) WriteMapEnd()               {}
+func (encDriverNoopContainerWriter) atEndOfEncode()             {}
 
 
 // type ioEncWriterWriter interface {
 // type ioEncWriterWriter interface {
 // 	WriteByte(c byte) error
 // 	WriteByte(c byte) error
@@ -104,6 +101,7 @@ func (_ encDriverNoopContainerWriter) atEndOfEncode()             {}
 // 	Write(p []byte) (n int, err error)
 // 	Write(p []byte) (n int, err error)
 // }
 // }
 
 
+// EncodeOptions captures configuration options during encode.
 type EncodeOptions struct {
 type EncodeOptions struct {
 	// Encode a struct as an array, and not as a map
 	// Encode a struct as an array, and not as a map
 	StructToArray bool
 	StructToArray bool
@@ -385,17 +383,17 @@ func (e *Encoder) selferMarshal(f *codecFnInfo, rv reflect.Value) {
 
 
 func (e *Encoder) binaryMarshal(f *codecFnInfo, rv reflect.Value) {
 func (e *Encoder) binaryMarshal(f *codecFnInfo, rv reflect.Value) {
 	bs, fnerr := rv2i(rv).(encoding.BinaryMarshaler).MarshalBinary()
 	bs, fnerr := rv2i(rv).(encoding.BinaryMarshaler).MarshalBinary()
-	e.marshal(bs, fnerr, false, c_RAW)
+	e.marshal(bs, fnerr, false, cRAW)
 }
 }
 
 
 func (e *Encoder) textMarshal(f *codecFnInfo, rv reflect.Value) {
 func (e *Encoder) textMarshal(f *codecFnInfo, rv reflect.Value) {
 	bs, fnerr := rv2i(rv).(encoding.TextMarshaler).MarshalText()
 	bs, fnerr := rv2i(rv).(encoding.TextMarshaler).MarshalText()
-	e.marshal(bs, fnerr, false, c_UTF8)
+	e.marshal(bs, fnerr, false, cUTF8)
 }
 }
 
 
 func (e *Encoder) jsonMarshal(f *codecFnInfo, rv reflect.Value) {
 func (e *Encoder) jsonMarshal(f *codecFnInfo, rv reflect.Value) {
 	bs, fnerr := rv2i(rv).(jsonMarshaler).MarshalJSON()
 	bs, fnerr := rv2i(rv).(jsonMarshaler).MarshalJSON()
-	e.marshal(bs, fnerr, true, c_UTF8)
+	e.marshal(bs, fnerr, true, cUTF8)
 }
 }
 
 
 func (e *Encoder) raw(f *codecFnInfo, rv reflect.Value) {
 func (e *Encoder) raw(f *codecFnInfo, rv reflect.Value) {
@@ -425,7 +423,7 @@ func (e *Encoder) kSlice(f *codecFnInfo, rv reflect.Value) {
 		// If in this method, then there was no extension function defined.
 		// If in this method, then there was no extension function defined.
 		// So it's okay to treat as []byte.
 		// So it's okay to treat as []byte.
 		if ti.rtid == uint8SliceTypId {
 		if ti.rtid == uint8SliceTypId {
-			ee.EncodeStringBytes(c_RAW, rv.Bytes())
+			ee.EncodeStringBytes(cRAW, rv.Bytes())
 			return
 			return
 		}
 		}
 	}
 	}
@@ -436,7 +434,7 @@ func (e *Encoder) kSlice(f *codecFnInfo, rv reflect.Value) {
 		switch f.seq {
 		switch f.seq {
 		case seqTypeArray:
 		case seqTypeArray:
 			if rv.CanAddr() {
 			if rv.CanAddr() {
-				ee.EncodeStringBytes(c_RAW, rv.Slice(0, l).Bytes())
+				ee.EncodeStringBytes(cRAW, rv.Slice(0, l).Bytes())
 			} else {
 			} else {
 				var bs []byte
 				var bs []byte
 				if l <= cap(e.b) {
 				if l <= cap(e.b) {
@@ -445,11 +443,11 @@ func (e *Encoder) kSlice(f *codecFnInfo, rv reflect.Value) {
 					bs = make([]byte, l)
 					bs = make([]byte, l)
 				}
 				}
 				reflect.Copy(reflect.ValueOf(bs), rv)
 				reflect.Copy(reflect.ValueOf(bs), rv)
-				ee.EncodeStringBytes(c_RAW, bs)
+				ee.EncodeStringBytes(cRAW, bs)
 			}
 			}
 			return
 			return
 		case seqTypeSlice:
 		case seqTypeSlice:
-			ee.EncodeStringBytes(c_RAW, rv.Bytes())
+			ee.EncodeStringBytes(cRAW, rv.Bytes())
 			return
 			return
 		}
 		}
 	}
 	}
@@ -462,7 +460,7 @@ func (e *Encoder) kSlice(f *codecFnInfo, rv reflect.Value) {
 		for i := 0; i < l; i++ {
 		for i := 0; i < l; i++ {
 			bs = append(bs, <-ch)
 			bs = append(bs, <-ch)
 		}
 		}
-		ee.EncodeStringBytes(c_RAW, bs)
+		ee.EncodeStringBytes(cRAW, bs)
 		return
 		return
 	}
 	}
 
 
@@ -539,7 +537,7 @@ func (e *Encoder) kStructNoOmitempty(f *codecFnInfo, rv reflect.Value) {
 				if asSymbols {
 				if asSymbols {
 					ee.EncodeSymbol(si.encName)
 					ee.EncodeSymbol(si.encName)
 				} else {
 				} else {
-					ee.EncodeString(c_UTF8, si.encName)
+					ee.EncodeString(cUTF8, si.encName)
 				}
 				}
 				e.encodeValue(sfn.field(si), nil, true)
 				e.encodeValue(sfn.field(si), nil, true)
 			}
 			}
@@ -549,7 +547,7 @@ func (e *Encoder) kStructNoOmitempty(f *codecFnInfo, rv reflect.Value) {
 				if asSymbols {
 				if asSymbols {
 					ee.EncodeSymbol(si.encName)
 					ee.EncodeSymbol(si.encName)
 				} else {
 				} else {
-					ee.EncodeString(c_UTF8, si.encName)
+					ee.EncodeString(cUTF8, si.encName)
 				}
 				}
 				ee.WriteMapElemValue()
 				ee.WriteMapElemValue()
 				e.encodeValue(sfn.field(si), nil, true)
 				e.encodeValue(sfn.field(si), nil, true)
@@ -654,7 +652,7 @@ func (e *Encoder) kStruct(f *codecFnInfo, rv reflect.Value) {
 				if asSymbols {
 				if asSymbols {
 					ee.EncodeSymbol(kv.v)
 					ee.EncodeSymbol(kv.v)
 				} else {
 				} else {
-					ee.EncodeString(c_UTF8, kv.v)
+					ee.EncodeString(cUTF8, kv.v)
 				}
 				}
 				e.encodeValue(kv.r, nil, true)
 				e.encodeValue(kv.r, nil, true)
 			}
 			}
@@ -665,7 +663,7 @@ func (e *Encoder) kStruct(f *codecFnInfo, rv reflect.Value) {
 				if asSymbols {
 				if asSymbols {
 					ee.EncodeSymbol(kv.v)
 					ee.EncodeSymbol(kv.v)
 				} else {
 				} else {
-					ee.EncodeString(c_UTF8, kv.v)
+					ee.EncodeString(cUTF8, kv.v)
 				}
 				}
 				ee.WriteMapElemValue()
 				ee.WriteMapElemValue()
 				e.encodeValue(kv.r, nil, true)
 				e.encodeValue(kv.r, nil, true)
@@ -723,7 +721,7 @@ func (e *Encoder) kMap(f *codecFnInfo, rv reflect.Value) {
 	rtkey := rtkey0
 	rtkey := rtkey0
 	rtval0 := ti.rt.Elem()
 	rtval0 := ti.rt.Elem()
 	rtval := rtval0
 	rtval := rtval0
-	rtkeyid := rt2id(rtkey0)
+	// rtkeyid := rt2id(rtkey0)
 	for rtval.Kind() == reflect.Ptr {
 	for rtval.Kind() == reflect.Ptr {
 		rtval = rtval.Elem()
 		rtval = rtval.Elem()
 	}
 	}
@@ -738,7 +736,7 @@ func (e *Encoder) kMap(f *codecFnInfo, rv reflect.Value) {
 		return
 		return
 	}
 	}
 
 
-	var keyTypeIsString = rtkeyid == stringTypId
+	var keyTypeIsString = stringTypId == rt2id(rtkey0) // rtkeyid
 	if keyTypeIsString {
 	if keyTypeIsString {
 		asSymbols = e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0
 		asSymbols = e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0
 	} else {
 	} else {
@@ -746,7 +744,7 @@ func (e *Encoder) kMap(f *codecFnInfo, rv reflect.Value) {
 			rtkey = rtkey.Elem()
 			rtkey = rtkey.Elem()
 		}
 		}
 		if rtkey.Kind() != reflect.Interface {
 		if rtkey.Kind() != reflect.Interface {
-			rtkeyid = rt2id(rtkey)
+			// rtkeyid = rt2id(rtkey)
 			keyFn = e.cf.get(rtkey, true, true)
 			keyFn = e.cf.get(rtkey, true, true)
 		}
 		}
 	}
 	}
@@ -760,7 +758,7 @@ func (e *Encoder) kMap(f *codecFnInfo, rv reflect.Value) {
 			if asSymbols {
 			if asSymbols {
 				ee.EncodeSymbol(mks[j].String())
 				ee.EncodeSymbol(mks[j].String())
 			} else {
 			} else {
-				ee.EncodeString(c_UTF8, mks[j].String())
+				ee.EncodeString(cUTF8, mks[j].String())
 			}
 			}
 		} else {
 		} else {
 			e.encodeValue(mks[j], keyFn, true)
 			e.encodeValue(mks[j], keyFn, true)
@@ -793,7 +791,7 @@ func (e *Encoder) kMapCanonical(rtkey reflect.Type, rv reflect.Value, mks []refl
 	// 		if elemsep {
 	// 		if elemsep {
 	// 			ee.WriteMapElemKey()
 	// 			ee.WriteMapElemKey()
 	// 		}
 	// 		}
-	// 		ee.EncodeStringBytes(c_RAW, mksv[i].v)
+	// 		ee.EncodeStringBytes(cRAW, mksv[i].v)
 	// 		if elemsep {
 	// 		if elemsep {
 	// 			ee.WriteMapElemValue()
 	// 			ee.WriteMapElemValue()
 	// 		}
 	// 		}
@@ -836,7 +834,7 @@ func (e *Encoder) kMapCanonical(rtkey reflect.Type, rv reflect.Value, mks []refl
 			if asSymbols {
 			if asSymbols {
 				ee.EncodeSymbol(mksv[i].v)
 				ee.EncodeSymbol(mksv[i].v)
 			} else {
 			} else {
-				ee.EncodeString(c_UTF8, mksv[i].v)
+				ee.EncodeString(cUTF8, mksv[i].v)
 			}
 			}
 			if elemsep {
 			if elemsep {
 				ee.WriteMapElemValue()
 				ee.WriteMapElemValue()
@@ -1001,7 +999,7 @@ func newEncoder(h Handle) *Encoder {
 	return e
 	return e
 }
 }
 
 
-// Reset the Encoder with a new output stream.
+// Reset resets the Encoder with a new output stream.
 //
 //
 // This accommodates using the state of the Encoder,
 // This accommodates using the state of the Encoder,
 // where it has "cached" information about sub-engines.
 // where it has "cached" information about sub-engines.
@@ -1031,6 +1029,7 @@ func (e *Encoder) Reset(w io.Writer) {
 	e.err = nil
 	e.err = nil
 }
 }
 
 
+// ResetBytes resets the Encoder with a new destination output []byte.
 func (e *Encoder) ResetBytes(out *[]byte) {
 func (e *Encoder) ResetBytes(out *[]byte) {
 	in := *out
 	in := *out
 	if in == nil {
 	if in == nil {
@@ -1141,7 +1140,7 @@ func (e *Encoder) encode(iv interface{}) {
 		e.encodeValue(v, nil, true)
 		e.encodeValue(v, nil, true)
 
 
 	case string:
 	case string:
-		e.e.EncodeString(c_UTF8, v)
+		e.e.EncodeString(cUTF8, v)
 	case bool:
 	case bool:
 		e.e.EncodeBool(v)
 		e.e.EncodeBool(v)
 	case int:
 	case int:
@@ -1172,10 +1171,10 @@ func (e *Encoder) encode(iv interface{}) {
 		e.e.EncodeFloat64(v)
 		e.e.EncodeFloat64(v)
 
 
 	case []uint8:
 	case []uint8:
-		e.e.EncodeStringBytes(c_RAW, v)
+		e.e.EncodeStringBytes(cRAW, v)
 
 
 	case *string:
 	case *string:
-		e.e.EncodeString(c_UTF8, *v)
+		e.e.EncodeString(cUTF8, *v)
 	case *bool:
 	case *bool:
 		e.e.EncodeBool(*v)
 		e.e.EncodeBool(*v)
 	case *int:
 	case *int:
@@ -1206,7 +1205,7 @@ func (e *Encoder) encode(iv interface{}) {
 		e.e.EncodeFloat64(*v)
 		e.e.EncodeFloat64(*v)
 
 
 	case *[]uint8:
 	case *[]uint8:
-		e.e.EncodeStringBytes(c_RAW, *v)
+		e.e.EncodeStringBytes(cRAW, *v)
 
 
 	default:
 	default:
 		if !fastpathEncodeTypeSwitch(iv, e) {
 		if !fastpathEncodeTypeSwitch(iv, e) {

+ 65 - 65
codec/fast-path.generated.go

@@ -1795,7 +1795,7 @@ func (_ fastpathT) EncSliceStringV(v []string, e *Encoder) {
 		if esep {
 		if esep {
 			ee.WriteArrayElem()
 			ee.WriteArrayElem()
 		}
 		}
-		ee.EncodeString(c_UTF8, v2)
+		ee.EncodeString(cUTF8, v2)
 	}
 	}
 	ee.WriteArrayEnd()
 	ee.WriteArrayEnd()
 }
 }
@@ -1815,7 +1815,7 @@ func (_ fastpathT) EncAsMapSliceStringV(v []string, e *Encoder) {
 				ee.WriteMapElemValue()
 				ee.WriteMapElemValue()
 			}
 			}
 		}
 		}
-		ee.EncodeString(c_UTF8, v2)
+		ee.EncodeString(cUTF8, v2)
 	}
 	}
 	ee.WriteMapEnd()
 	ee.WriteMapEnd()
 }
 }
@@ -2473,7 +2473,7 @@ func (_ fastpathT) EncMapIntfStringV(v map[interface{}]string, e *Encoder) {
 			if esep {
 			if esep {
 				ee.WriteMapElemValue()
 				ee.WriteMapElemValue()
 			}
 			}
-			ee.EncodeString(c_UTF8, v2)
+			ee.EncodeString(cUTF8, v2)
 		}
 		}
 	}
 	}
 	ee.WriteMapEnd()
 	ee.WriteMapEnd()
@@ -3205,7 +3205,7 @@ func (_ fastpathT) EncMapStringIntfV(v map[string]interface{}, e *Encoder) {
 			if asSymbols {
 			if asSymbols {
 				ee.EncodeSymbol(k2)
 				ee.EncodeSymbol(k2)
 			} else {
 			} else {
-				ee.EncodeString(c_UTF8, k2)
+				ee.EncodeString(cUTF8, k2)
 			}
 			}
 			if esep {
 			if esep {
 				ee.WriteMapElemValue()
 				ee.WriteMapElemValue()
@@ -3220,7 +3220,7 @@ func (_ fastpathT) EncMapStringIntfV(v map[string]interface{}, e *Encoder) {
 			if asSymbols {
 			if asSymbols {
 				ee.EncodeSymbol(k2)
 				ee.EncodeSymbol(k2)
 			} else {
 			} else {
-				ee.EncodeString(c_UTF8, k2)
+				ee.EncodeString(cUTF8, k2)
 			}
 			}
 			if esep {
 			if esep {
 				ee.WriteMapElemValue()
 				ee.WriteMapElemValue()
@@ -3257,12 +3257,12 @@ func (_ fastpathT) EncMapStringStringV(v map[string]string, e *Encoder) {
 			if asSymbols {
 			if asSymbols {
 				ee.EncodeSymbol(k2)
 				ee.EncodeSymbol(k2)
 			} else {
 			} else {
-				ee.EncodeString(c_UTF8, k2)
+				ee.EncodeString(cUTF8, k2)
 			}
 			}
 			if esep {
 			if esep {
 				ee.WriteMapElemValue()
 				ee.WriteMapElemValue()
 			}
 			}
-			ee.EncodeString(c_UTF8, v[string(k2)])
+			ee.EncodeString(cUTF8, v[string(k2)])
 		}
 		}
 	} else {
 	} else {
 		for k2, v2 := range v {
 		for k2, v2 := range v {
@@ -3272,12 +3272,12 @@ func (_ fastpathT) EncMapStringStringV(v map[string]string, e *Encoder) {
 			if asSymbols {
 			if asSymbols {
 				ee.EncodeSymbol(k2)
 				ee.EncodeSymbol(k2)
 			} else {
 			} else {
-				ee.EncodeString(c_UTF8, k2)
+				ee.EncodeString(cUTF8, k2)
 			}
 			}
 			if esep {
 			if esep {
 				ee.WriteMapElemValue()
 				ee.WriteMapElemValue()
 			}
 			}
-			ee.EncodeString(c_UTF8, v2)
+			ee.EncodeString(cUTF8, v2)
 		}
 		}
 	}
 	}
 	ee.WriteMapEnd()
 	ee.WriteMapEnd()
@@ -3309,7 +3309,7 @@ func (_ fastpathT) EncMapStringUintV(v map[string]uint, e *Encoder) {
 			if asSymbols {
 			if asSymbols {
 				ee.EncodeSymbol(k2)
 				ee.EncodeSymbol(k2)
 			} else {
 			} else {
-				ee.EncodeString(c_UTF8, k2)
+				ee.EncodeString(cUTF8, k2)
 			}
 			}
 			if esep {
 			if esep {
 				ee.WriteMapElemValue()
 				ee.WriteMapElemValue()
@@ -3324,7 +3324,7 @@ func (_ fastpathT) EncMapStringUintV(v map[string]uint, e *Encoder) {
 			if asSymbols {
 			if asSymbols {
 				ee.EncodeSymbol(k2)
 				ee.EncodeSymbol(k2)
 			} else {
 			} else {
-				ee.EncodeString(c_UTF8, k2)
+				ee.EncodeString(cUTF8, k2)
 			}
 			}
 			if esep {
 			if esep {
 				ee.WriteMapElemValue()
 				ee.WriteMapElemValue()
@@ -3361,7 +3361,7 @@ func (_ fastpathT) EncMapStringUint8V(v map[string]uint8, e *Encoder) {
 			if asSymbols {
 			if asSymbols {
 				ee.EncodeSymbol(k2)
 				ee.EncodeSymbol(k2)
 			} else {
 			} else {
-				ee.EncodeString(c_UTF8, k2)
+				ee.EncodeString(cUTF8, k2)
 			}
 			}
 			if esep {
 			if esep {
 				ee.WriteMapElemValue()
 				ee.WriteMapElemValue()
@@ -3376,7 +3376,7 @@ func (_ fastpathT) EncMapStringUint8V(v map[string]uint8, e *Encoder) {
 			if asSymbols {
 			if asSymbols {
 				ee.EncodeSymbol(k2)
 				ee.EncodeSymbol(k2)
 			} else {
 			} else {
-				ee.EncodeString(c_UTF8, k2)
+				ee.EncodeString(cUTF8, k2)
 			}
 			}
 			if esep {
 			if esep {
 				ee.WriteMapElemValue()
 				ee.WriteMapElemValue()
@@ -3413,7 +3413,7 @@ func (_ fastpathT) EncMapStringUint16V(v map[string]uint16, e *Encoder) {
 			if asSymbols {
 			if asSymbols {
 				ee.EncodeSymbol(k2)
 				ee.EncodeSymbol(k2)
 			} else {
 			} else {
-				ee.EncodeString(c_UTF8, k2)
+				ee.EncodeString(cUTF8, k2)
 			}
 			}
 			if esep {
 			if esep {
 				ee.WriteMapElemValue()
 				ee.WriteMapElemValue()
@@ -3428,7 +3428,7 @@ func (_ fastpathT) EncMapStringUint16V(v map[string]uint16, e *Encoder) {
 			if asSymbols {
 			if asSymbols {
 				ee.EncodeSymbol(k2)
 				ee.EncodeSymbol(k2)
 			} else {
 			} else {
-				ee.EncodeString(c_UTF8, k2)
+				ee.EncodeString(cUTF8, k2)
 			}
 			}
 			if esep {
 			if esep {
 				ee.WriteMapElemValue()
 				ee.WriteMapElemValue()
@@ -3465,7 +3465,7 @@ func (_ fastpathT) EncMapStringUint32V(v map[string]uint32, e *Encoder) {
 			if asSymbols {
 			if asSymbols {
 				ee.EncodeSymbol(k2)
 				ee.EncodeSymbol(k2)
 			} else {
 			} else {
-				ee.EncodeString(c_UTF8, k2)
+				ee.EncodeString(cUTF8, k2)
 			}
 			}
 			if esep {
 			if esep {
 				ee.WriteMapElemValue()
 				ee.WriteMapElemValue()
@@ -3480,7 +3480,7 @@ func (_ fastpathT) EncMapStringUint32V(v map[string]uint32, e *Encoder) {
 			if asSymbols {
 			if asSymbols {
 				ee.EncodeSymbol(k2)
 				ee.EncodeSymbol(k2)
 			} else {
 			} else {
-				ee.EncodeString(c_UTF8, k2)
+				ee.EncodeString(cUTF8, k2)
 			}
 			}
 			if esep {
 			if esep {
 				ee.WriteMapElemValue()
 				ee.WriteMapElemValue()
@@ -3517,7 +3517,7 @@ func (_ fastpathT) EncMapStringUint64V(v map[string]uint64, e *Encoder) {
 			if asSymbols {
 			if asSymbols {
 				ee.EncodeSymbol(k2)
 				ee.EncodeSymbol(k2)
 			} else {
 			} else {
-				ee.EncodeString(c_UTF8, k2)
+				ee.EncodeString(cUTF8, k2)
 			}
 			}
 			if esep {
 			if esep {
 				ee.WriteMapElemValue()
 				ee.WriteMapElemValue()
@@ -3532,7 +3532,7 @@ func (_ fastpathT) EncMapStringUint64V(v map[string]uint64, e *Encoder) {
 			if asSymbols {
 			if asSymbols {
 				ee.EncodeSymbol(k2)
 				ee.EncodeSymbol(k2)
 			} else {
 			} else {
-				ee.EncodeString(c_UTF8, k2)
+				ee.EncodeString(cUTF8, k2)
 			}
 			}
 			if esep {
 			if esep {
 				ee.WriteMapElemValue()
 				ee.WriteMapElemValue()
@@ -3569,7 +3569,7 @@ func (_ fastpathT) EncMapStringUintptrV(v map[string]uintptr, e *Encoder) {
 			if asSymbols {
 			if asSymbols {
 				ee.EncodeSymbol(k2)
 				ee.EncodeSymbol(k2)
 			} else {
 			} else {
-				ee.EncodeString(c_UTF8, k2)
+				ee.EncodeString(cUTF8, k2)
 			}
 			}
 			if esep {
 			if esep {
 				ee.WriteMapElemValue()
 				ee.WriteMapElemValue()
@@ -3584,7 +3584,7 @@ func (_ fastpathT) EncMapStringUintptrV(v map[string]uintptr, e *Encoder) {
 			if asSymbols {
 			if asSymbols {
 				ee.EncodeSymbol(k2)
 				ee.EncodeSymbol(k2)
 			} else {
 			} else {
-				ee.EncodeString(c_UTF8, k2)
+				ee.EncodeString(cUTF8, k2)
 			}
 			}
 			if esep {
 			if esep {
 				ee.WriteMapElemValue()
 				ee.WriteMapElemValue()
@@ -3621,7 +3621,7 @@ func (_ fastpathT) EncMapStringIntV(v map[string]int, e *Encoder) {
 			if asSymbols {
 			if asSymbols {
 				ee.EncodeSymbol(k2)
 				ee.EncodeSymbol(k2)
 			} else {
 			} else {
-				ee.EncodeString(c_UTF8, k2)
+				ee.EncodeString(cUTF8, k2)
 			}
 			}
 			if esep {
 			if esep {
 				ee.WriteMapElemValue()
 				ee.WriteMapElemValue()
@@ -3636,7 +3636,7 @@ func (_ fastpathT) EncMapStringIntV(v map[string]int, e *Encoder) {
 			if asSymbols {
 			if asSymbols {
 				ee.EncodeSymbol(k2)
 				ee.EncodeSymbol(k2)
 			} else {
 			} else {
-				ee.EncodeString(c_UTF8, k2)
+				ee.EncodeString(cUTF8, k2)
 			}
 			}
 			if esep {
 			if esep {
 				ee.WriteMapElemValue()
 				ee.WriteMapElemValue()
@@ -3673,7 +3673,7 @@ func (_ fastpathT) EncMapStringInt8V(v map[string]int8, e *Encoder) {
 			if asSymbols {
 			if asSymbols {
 				ee.EncodeSymbol(k2)
 				ee.EncodeSymbol(k2)
 			} else {
 			} else {
-				ee.EncodeString(c_UTF8, k2)
+				ee.EncodeString(cUTF8, k2)
 			}
 			}
 			if esep {
 			if esep {
 				ee.WriteMapElemValue()
 				ee.WriteMapElemValue()
@@ -3688,7 +3688,7 @@ func (_ fastpathT) EncMapStringInt8V(v map[string]int8, e *Encoder) {
 			if asSymbols {
 			if asSymbols {
 				ee.EncodeSymbol(k2)
 				ee.EncodeSymbol(k2)
 			} else {
 			} else {
-				ee.EncodeString(c_UTF8, k2)
+				ee.EncodeString(cUTF8, k2)
 			}
 			}
 			if esep {
 			if esep {
 				ee.WriteMapElemValue()
 				ee.WriteMapElemValue()
@@ -3725,7 +3725,7 @@ func (_ fastpathT) EncMapStringInt16V(v map[string]int16, e *Encoder) {
 			if asSymbols {
 			if asSymbols {
 				ee.EncodeSymbol(k2)
 				ee.EncodeSymbol(k2)
 			} else {
 			} else {
-				ee.EncodeString(c_UTF8, k2)
+				ee.EncodeString(cUTF8, k2)
 			}
 			}
 			if esep {
 			if esep {
 				ee.WriteMapElemValue()
 				ee.WriteMapElemValue()
@@ -3740,7 +3740,7 @@ func (_ fastpathT) EncMapStringInt16V(v map[string]int16, e *Encoder) {
 			if asSymbols {
 			if asSymbols {
 				ee.EncodeSymbol(k2)
 				ee.EncodeSymbol(k2)
 			} else {
 			} else {
-				ee.EncodeString(c_UTF8, k2)
+				ee.EncodeString(cUTF8, k2)
 			}
 			}
 			if esep {
 			if esep {
 				ee.WriteMapElemValue()
 				ee.WriteMapElemValue()
@@ -3777,7 +3777,7 @@ func (_ fastpathT) EncMapStringInt32V(v map[string]int32, e *Encoder) {
 			if asSymbols {
 			if asSymbols {
 				ee.EncodeSymbol(k2)
 				ee.EncodeSymbol(k2)
 			} else {
 			} else {
-				ee.EncodeString(c_UTF8, k2)
+				ee.EncodeString(cUTF8, k2)
 			}
 			}
 			if esep {
 			if esep {
 				ee.WriteMapElemValue()
 				ee.WriteMapElemValue()
@@ -3792,7 +3792,7 @@ func (_ fastpathT) EncMapStringInt32V(v map[string]int32, e *Encoder) {
 			if asSymbols {
 			if asSymbols {
 				ee.EncodeSymbol(k2)
 				ee.EncodeSymbol(k2)
 			} else {
 			} else {
-				ee.EncodeString(c_UTF8, k2)
+				ee.EncodeString(cUTF8, k2)
 			}
 			}
 			if esep {
 			if esep {
 				ee.WriteMapElemValue()
 				ee.WriteMapElemValue()
@@ -3829,7 +3829,7 @@ func (_ fastpathT) EncMapStringInt64V(v map[string]int64, e *Encoder) {
 			if asSymbols {
 			if asSymbols {
 				ee.EncodeSymbol(k2)
 				ee.EncodeSymbol(k2)
 			} else {
 			} else {
-				ee.EncodeString(c_UTF8, k2)
+				ee.EncodeString(cUTF8, k2)
 			}
 			}
 			if esep {
 			if esep {
 				ee.WriteMapElemValue()
 				ee.WriteMapElemValue()
@@ -3844,7 +3844,7 @@ func (_ fastpathT) EncMapStringInt64V(v map[string]int64, e *Encoder) {
 			if asSymbols {
 			if asSymbols {
 				ee.EncodeSymbol(k2)
 				ee.EncodeSymbol(k2)
 			} else {
 			} else {
-				ee.EncodeString(c_UTF8, k2)
+				ee.EncodeString(cUTF8, k2)
 			}
 			}
 			if esep {
 			if esep {
 				ee.WriteMapElemValue()
 				ee.WriteMapElemValue()
@@ -3881,7 +3881,7 @@ func (_ fastpathT) EncMapStringFloat32V(v map[string]float32, e *Encoder) {
 			if asSymbols {
 			if asSymbols {
 				ee.EncodeSymbol(k2)
 				ee.EncodeSymbol(k2)
 			} else {
 			} else {
-				ee.EncodeString(c_UTF8, k2)
+				ee.EncodeString(cUTF8, k2)
 			}
 			}
 			if esep {
 			if esep {
 				ee.WriteMapElemValue()
 				ee.WriteMapElemValue()
@@ -3896,7 +3896,7 @@ func (_ fastpathT) EncMapStringFloat32V(v map[string]float32, e *Encoder) {
 			if asSymbols {
 			if asSymbols {
 				ee.EncodeSymbol(k2)
 				ee.EncodeSymbol(k2)
 			} else {
 			} else {
-				ee.EncodeString(c_UTF8, k2)
+				ee.EncodeString(cUTF8, k2)
 			}
 			}
 			if esep {
 			if esep {
 				ee.WriteMapElemValue()
 				ee.WriteMapElemValue()
@@ -3933,7 +3933,7 @@ func (_ fastpathT) EncMapStringFloat64V(v map[string]float64, e *Encoder) {
 			if asSymbols {
 			if asSymbols {
 				ee.EncodeSymbol(k2)
 				ee.EncodeSymbol(k2)
 			} else {
 			} else {
-				ee.EncodeString(c_UTF8, k2)
+				ee.EncodeString(cUTF8, k2)
 			}
 			}
 			if esep {
 			if esep {
 				ee.WriteMapElemValue()
 				ee.WriteMapElemValue()
@@ -3948,7 +3948,7 @@ func (_ fastpathT) EncMapStringFloat64V(v map[string]float64, e *Encoder) {
 			if asSymbols {
 			if asSymbols {
 				ee.EncodeSymbol(k2)
 				ee.EncodeSymbol(k2)
 			} else {
 			} else {
-				ee.EncodeString(c_UTF8, k2)
+				ee.EncodeString(cUTF8, k2)
 			}
 			}
 			if esep {
 			if esep {
 				ee.WriteMapElemValue()
 				ee.WriteMapElemValue()
@@ -3985,7 +3985,7 @@ func (_ fastpathT) EncMapStringBoolV(v map[string]bool, e *Encoder) {
 			if asSymbols {
 			if asSymbols {
 				ee.EncodeSymbol(k2)
 				ee.EncodeSymbol(k2)
 			} else {
 			} else {
-				ee.EncodeString(c_UTF8, k2)
+				ee.EncodeString(cUTF8, k2)
 			}
 			}
 			if esep {
 			if esep {
 				ee.WriteMapElemValue()
 				ee.WriteMapElemValue()
@@ -4000,7 +4000,7 @@ func (_ fastpathT) EncMapStringBoolV(v map[string]bool, e *Encoder) {
 			if asSymbols {
 			if asSymbols {
 				ee.EncodeSymbol(k2)
 				ee.EncodeSymbol(k2)
 			} else {
 			} else {
-				ee.EncodeString(c_UTF8, k2)
+				ee.EncodeString(cUTF8, k2)
 			}
 			}
 			if esep {
 			if esep {
 				ee.WriteMapElemValue()
 				ee.WriteMapElemValue()
@@ -4080,7 +4080,7 @@ func (_ fastpathT) EncMapFloat32StringV(v map[float32]string, e *Encoder) {
 			if esep {
 			if esep {
 				ee.WriteMapElemValue()
 				ee.WriteMapElemValue()
 			}
 			}
-			ee.EncodeString(c_UTF8, v[float32(k2)])
+			ee.EncodeString(cUTF8, v[float32(k2)])
 		}
 		}
 	} else {
 	} else {
 		for k2, v2 := range v {
 		for k2, v2 := range v {
@@ -4091,7 +4091,7 @@ func (_ fastpathT) EncMapFloat32StringV(v map[float32]string, e *Encoder) {
 			if esep {
 			if esep {
 				ee.WriteMapElemValue()
 				ee.WriteMapElemValue()
 			}
 			}
-			ee.EncodeString(c_UTF8, v2)
+			ee.EncodeString(cUTF8, v2)
 		}
 		}
 	}
 	}
 	ee.WriteMapEnd()
 	ee.WriteMapEnd()
@@ -4768,7 +4768,7 @@ func (_ fastpathT) EncMapFloat64StringV(v map[float64]string, e *Encoder) {
 			if esep {
 			if esep {
 				ee.WriteMapElemValue()
 				ee.WriteMapElemValue()
 			}
 			}
-			ee.EncodeString(c_UTF8, v[float64(k2)])
+			ee.EncodeString(cUTF8, v[float64(k2)])
 		}
 		}
 	} else {
 	} else {
 		for k2, v2 := range v {
 		for k2, v2 := range v {
@@ -4779,7 +4779,7 @@ func (_ fastpathT) EncMapFloat64StringV(v map[float64]string, e *Encoder) {
 			if esep {
 			if esep {
 				ee.WriteMapElemValue()
 				ee.WriteMapElemValue()
 			}
 			}
-			ee.EncodeString(c_UTF8, v2)
+			ee.EncodeString(cUTF8, v2)
 		}
 		}
 	}
 	}
 	ee.WriteMapEnd()
 	ee.WriteMapEnd()
@@ -5456,7 +5456,7 @@ func (_ fastpathT) EncMapUintStringV(v map[uint]string, e *Encoder) {
 			if esep {
 			if esep {
 				ee.WriteMapElemValue()
 				ee.WriteMapElemValue()
 			}
 			}
-			ee.EncodeString(c_UTF8, v[uint(k2)])
+			ee.EncodeString(cUTF8, v[uint(k2)])
 		}
 		}
 	} else {
 	} else {
 		for k2, v2 := range v {
 		for k2, v2 := range v {
@@ -5467,7 +5467,7 @@ func (_ fastpathT) EncMapUintStringV(v map[uint]string, e *Encoder) {
 			if esep {
 			if esep {
 				ee.WriteMapElemValue()
 				ee.WriteMapElemValue()
 			}
 			}
-			ee.EncodeString(c_UTF8, v2)
+			ee.EncodeString(cUTF8, v2)
 		}
 		}
 	}
 	}
 	ee.WriteMapEnd()
 	ee.WriteMapEnd()
@@ -6144,7 +6144,7 @@ func (_ fastpathT) EncMapUint8StringV(v map[uint8]string, e *Encoder) {
 			if esep {
 			if esep {
 				ee.WriteMapElemValue()
 				ee.WriteMapElemValue()
 			}
 			}
-			ee.EncodeString(c_UTF8, v[uint8(k2)])
+			ee.EncodeString(cUTF8, v[uint8(k2)])
 		}
 		}
 	} else {
 	} else {
 		for k2, v2 := range v {
 		for k2, v2 := range v {
@@ -6155,7 +6155,7 @@ func (_ fastpathT) EncMapUint8StringV(v map[uint8]string, e *Encoder) {
 			if esep {
 			if esep {
 				ee.WriteMapElemValue()
 				ee.WriteMapElemValue()
 			}
 			}
-			ee.EncodeString(c_UTF8, v2)
+			ee.EncodeString(cUTF8, v2)
 		}
 		}
 	}
 	}
 	ee.WriteMapEnd()
 	ee.WriteMapEnd()
@@ -6832,7 +6832,7 @@ func (_ fastpathT) EncMapUint16StringV(v map[uint16]string, e *Encoder) {
 			if esep {
 			if esep {
 				ee.WriteMapElemValue()
 				ee.WriteMapElemValue()
 			}
 			}
-			ee.EncodeString(c_UTF8, v[uint16(k2)])
+			ee.EncodeString(cUTF8, v[uint16(k2)])
 		}
 		}
 	} else {
 	} else {
 		for k2, v2 := range v {
 		for k2, v2 := range v {
@@ -6843,7 +6843,7 @@ func (_ fastpathT) EncMapUint16StringV(v map[uint16]string, e *Encoder) {
 			if esep {
 			if esep {
 				ee.WriteMapElemValue()
 				ee.WriteMapElemValue()
 			}
 			}
-			ee.EncodeString(c_UTF8, v2)
+			ee.EncodeString(cUTF8, v2)
 		}
 		}
 	}
 	}
 	ee.WriteMapEnd()
 	ee.WriteMapEnd()
@@ -7520,7 +7520,7 @@ func (_ fastpathT) EncMapUint32StringV(v map[uint32]string, e *Encoder) {
 			if esep {
 			if esep {
 				ee.WriteMapElemValue()
 				ee.WriteMapElemValue()
 			}
 			}
-			ee.EncodeString(c_UTF8, v[uint32(k2)])
+			ee.EncodeString(cUTF8, v[uint32(k2)])
 		}
 		}
 	} else {
 	} else {
 		for k2, v2 := range v {
 		for k2, v2 := range v {
@@ -7531,7 +7531,7 @@ func (_ fastpathT) EncMapUint32StringV(v map[uint32]string, e *Encoder) {
 			if esep {
 			if esep {
 				ee.WriteMapElemValue()
 				ee.WriteMapElemValue()
 			}
 			}
-			ee.EncodeString(c_UTF8, v2)
+			ee.EncodeString(cUTF8, v2)
 		}
 		}
 	}
 	}
 	ee.WriteMapEnd()
 	ee.WriteMapEnd()
@@ -8208,7 +8208,7 @@ func (_ fastpathT) EncMapUint64StringV(v map[uint64]string, e *Encoder) {
 			if esep {
 			if esep {
 				ee.WriteMapElemValue()
 				ee.WriteMapElemValue()
 			}
 			}
-			ee.EncodeString(c_UTF8, v[uint64(k2)])
+			ee.EncodeString(cUTF8, v[uint64(k2)])
 		}
 		}
 	} else {
 	} else {
 		for k2, v2 := range v {
 		for k2, v2 := range v {
@@ -8219,7 +8219,7 @@ func (_ fastpathT) EncMapUint64StringV(v map[uint64]string, e *Encoder) {
 			if esep {
 			if esep {
 				ee.WriteMapElemValue()
 				ee.WriteMapElemValue()
 			}
 			}
-			ee.EncodeString(c_UTF8, v2)
+			ee.EncodeString(cUTF8, v2)
 		}
 		}
 	}
 	}
 	ee.WriteMapEnd()
 	ee.WriteMapEnd()
@@ -8896,7 +8896,7 @@ func (_ fastpathT) EncMapUintptrStringV(v map[uintptr]string, e *Encoder) {
 			if esep {
 			if esep {
 				ee.WriteMapElemValue()
 				ee.WriteMapElemValue()
 			}
 			}
-			ee.EncodeString(c_UTF8, v[uintptr(k2)])
+			ee.EncodeString(cUTF8, v[uintptr(k2)])
 		}
 		}
 	} else {
 	} else {
 		for k2, v2 := range v {
 		for k2, v2 := range v {
@@ -8907,7 +8907,7 @@ func (_ fastpathT) EncMapUintptrStringV(v map[uintptr]string, e *Encoder) {
 			if esep {
 			if esep {
 				ee.WriteMapElemValue()
 				ee.WriteMapElemValue()
 			}
 			}
-			ee.EncodeString(c_UTF8, v2)
+			ee.EncodeString(cUTF8, v2)
 		}
 		}
 	}
 	}
 	ee.WriteMapEnd()
 	ee.WriteMapEnd()
@@ -9584,7 +9584,7 @@ func (_ fastpathT) EncMapIntStringV(v map[int]string, e *Encoder) {
 			if esep {
 			if esep {
 				ee.WriteMapElemValue()
 				ee.WriteMapElemValue()
 			}
 			}
-			ee.EncodeString(c_UTF8, v[int(k2)])
+			ee.EncodeString(cUTF8, v[int(k2)])
 		}
 		}
 	} else {
 	} else {
 		for k2, v2 := range v {
 		for k2, v2 := range v {
@@ -9595,7 +9595,7 @@ func (_ fastpathT) EncMapIntStringV(v map[int]string, e *Encoder) {
 			if esep {
 			if esep {
 				ee.WriteMapElemValue()
 				ee.WriteMapElemValue()
 			}
 			}
-			ee.EncodeString(c_UTF8, v2)
+			ee.EncodeString(cUTF8, v2)
 		}
 		}
 	}
 	}
 	ee.WriteMapEnd()
 	ee.WriteMapEnd()
@@ -10272,7 +10272,7 @@ func (_ fastpathT) EncMapInt8StringV(v map[int8]string, e *Encoder) {
 			if esep {
 			if esep {
 				ee.WriteMapElemValue()
 				ee.WriteMapElemValue()
 			}
 			}
-			ee.EncodeString(c_UTF8, v[int8(k2)])
+			ee.EncodeString(cUTF8, v[int8(k2)])
 		}
 		}
 	} else {
 	} else {
 		for k2, v2 := range v {
 		for k2, v2 := range v {
@@ -10283,7 +10283,7 @@ func (_ fastpathT) EncMapInt8StringV(v map[int8]string, e *Encoder) {
 			if esep {
 			if esep {
 				ee.WriteMapElemValue()
 				ee.WriteMapElemValue()
 			}
 			}
-			ee.EncodeString(c_UTF8, v2)
+			ee.EncodeString(cUTF8, v2)
 		}
 		}
 	}
 	}
 	ee.WriteMapEnd()
 	ee.WriteMapEnd()
@@ -10960,7 +10960,7 @@ func (_ fastpathT) EncMapInt16StringV(v map[int16]string, e *Encoder) {
 			if esep {
 			if esep {
 				ee.WriteMapElemValue()
 				ee.WriteMapElemValue()
 			}
 			}
-			ee.EncodeString(c_UTF8, v[int16(k2)])
+			ee.EncodeString(cUTF8, v[int16(k2)])
 		}
 		}
 	} else {
 	} else {
 		for k2, v2 := range v {
 		for k2, v2 := range v {
@@ -10971,7 +10971,7 @@ func (_ fastpathT) EncMapInt16StringV(v map[int16]string, e *Encoder) {
 			if esep {
 			if esep {
 				ee.WriteMapElemValue()
 				ee.WriteMapElemValue()
 			}
 			}
-			ee.EncodeString(c_UTF8, v2)
+			ee.EncodeString(cUTF8, v2)
 		}
 		}
 	}
 	}
 	ee.WriteMapEnd()
 	ee.WriteMapEnd()
@@ -11648,7 +11648,7 @@ func (_ fastpathT) EncMapInt32StringV(v map[int32]string, e *Encoder) {
 			if esep {
 			if esep {
 				ee.WriteMapElemValue()
 				ee.WriteMapElemValue()
 			}
 			}
-			ee.EncodeString(c_UTF8, v[int32(k2)])
+			ee.EncodeString(cUTF8, v[int32(k2)])
 		}
 		}
 	} else {
 	} else {
 		for k2, v2 := range v {
 		for k2, v2 := range v {
@@ -11659,7 +11659,7 @@ func (_ fastpathT) EncMapInt32StringV(v map[int32]string, e *Encoder) {
 			if esep {
 			if esep {
 				ee.WriteMapElemValue()
 				ee.WriteMapElemValue()
 			}
 			}
-			ee.EncodeString(c_UTF8, v2)
+			ee.EncodeString(cUTF8, v2)
 		}
 		}
 	}
 	}
 	ee.WriteMapEnd()
 	ee.WriteMapEnd()
@@ -12336,7 +12336,7 @@ func (_ fastpathT) EncMapInt64StringV(v map[int64]string, e *Encoder) {
 			if esep {
 			if esep {
 				ee.WriteMapElemValue()
 				ee.WriteMapElemValue()
 			}
 			}
-			ee.EncodeString(c_UTF8, v[int64(k2)])
+			ee.EncodeString(cUTF8, v[int64(k2)])
 		}
 		}
 	} else {
 	} else {
 		for k2, v2 := range v {
 		for k2, v2 := range v {
@@ -12347,7 +12347,7 @@ func (_ fastpathT) EncMapInt64StringV(v map[int64]string, e *Encoder) {
 			if esep {
 			if esep {
 				ee.WriteMapElemValue()
 				ee.WriteMapElemValue()
 			}
 			}
-			ee.EncodeString(c_UTF8, v2)
+			ee.EncodeString(cUTF8, v2)
 		}
 		}
 	}
 	}
 	ee.WriteMapEnd()
 	ee.WriteMapEnd()
@@ -13024,7 +13024,7 @@ func (_ fastpathT) EncMapBoolStringV(v map[bool]string, e *Encoder) {
 			if esep {
 			if esep {
 				ee.WriteMapElemValue()
 				ee.WriteMapElemValue()
 			}
 			}
-			ee.EncodeString(c_UTF8, v[bool(k2)])
+			ee.EncodeString(cUTF8, v[bool(k2)])
 		}
 		}
 	} else {
 	} else {
 		for k2, v2 := range v {
 		for k2, v2 := range v {
@@ -13035,7 +13035,7 @@ func (_ fastpathT) EncMapBoolStringV(v map[bool]string, e *Encoder) {
 			if esep {
 			if esep {
 				ee.WriteMapElemValue()
 				ee.WriteMapElemValue()
 			}
 			}
-			ee.EncodeString(c_UTF8, v2)
+			ee.EncodeString(cUTF8, v2)
 		}
 		}
 	}
 	}
 	ee.WriteMapEnd()
 	ee.WriteMapEnd()

+ 2 - 2
codec/fast-path.go.tmpl

@@ -235,7 +235,7 @@ func (_ fastpathT) {{ .MethodNamePfx "Enc" false }}V(v map[{{ .MapKey }}]{{ .Ele
 			{{if eq .MapKey "string"}}if asSymbols {
 			{{if eq .MapKey "string"}}if asSymbols {
 				ee.EncodeSymbol(k2)
 				ee.EncodeSymbol(k2)
 			} else {
 			} else {
-				ee.EncodeString(c_UTF8, k2)
+				ee.EncodeString(cUTF8, k2)
 			}{{else}}{{ $y := printf "%s(k2)" .MapKey }}{{ encmd .MapKey $y }}{{end}}
 			}{{else}}{{ $y := printf "%s(k2)" .MapKey }}{{ encmd .MapKey $y }}{{end}}
 			if esep { ee.WriteMapElemValue() }
 			if esep { ee.WriteMapElemValue() }
 			{{ $y := printf "v[%s(k2)]" .MapKey }}{{ encmd .Elem $y }}
 			{{ $y := printf "v[%s(k2)]" .MapKey }}{{ encmd .Elem $y }}
@@ -246,7 +246,7 @@ func (_ fastpathT) {{ .MethodNamePfx "Enc" false }}V(v map[{{ .MapKey }}]{{ .Ele
 			{{if eq .MapKey "string"}}if asSymbols {
 			{{if eq .MapKey "string"}}if asSymbols {
 				ee.EncodeSymbol(k2)
 				ee.EncodeSymbol(k2)
 			} else {
 			} else {
-				ee.EncodeString(c_UTF8, k2)
+				ee.EncodeString(cUTF8, k2)
 			}{{else}}{{ encmd .MapKey "k2"}}{{end}}
 			}{{else}}{{ encmd .MapKey "k2"}}{{end}}
 			if esep { ee.WriteMapElemValue() }
 			if esep { ee.WriteMapElemValue() }
 			{{ encmd .Elem "v2"}}
 			{{ encmd .Elem "v2"}}

+ 3 - 3
codec/gen-helper.generated.go

@@ -71,19 +71,19 @@ func (f genHelperEncoder) EncFallback(iv interface{}) {
 // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
 // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
 func (f genHelperEncoder) EncTextMarshal(iv encoding.TextMarshaler) {
 func (f genHelperEncoder) EncTextMarshal(iv encoding.TextMarshaler) {
 	bs, fnerr := iv.MarshalText()
 	bs, fnerr := iv.MarshalText()
-	f.e.marshal(bs, fnerr, false, c_UTF8)
+	f.e.marshal(bs, fnerr, false, cUTF8)
 }
 }
 
 
 // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
 // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
 func (f genHelperEncoder) EncJSONMarshal(iv jsonMarshaler) {
 func (f genHelperEncoder) EncJSONMarshal(iv jsonMarshaler) {
 	bs, fnerr := iv.MarshalJSON()
 	bs, fnerr := iv.MarshalJSON()
-	f.e.marshal(bs, fnerr, true, c_UTF8)
+	f.e.marshal(bs, fnerr, true, cUTF8)
 }
 }
 
 
 // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
 // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
 func (f genHelperEncoder) EncBinaryMarshal(iv encoding.BinaryMarshaler) {
 func (f genHelperEncoder) EncBinaryMarshal(iv encoding.BinaryMarshaler) {
 	bs, fnerr := iv.MarshalBinary()
 	bs, fnerr := iv.MarshalBinary()
-	f.e.marshal(bs, fnerr, false, c_RAW)
+	f.e.marshal(bs, fnerr, false, cRAW)
 }
 }
 
 
 // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
 // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*

+ 3 - 3
codec/gen-helper.go.tmpl

@@ -69,17 +69,17 @@ func (f genHelperEncoder) EncFallback(iv interface{}) {
 // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
 // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
 func (f genHelperEncoder) EncTextMarshal(iv encoding.TextMarshaler) {
 func (f genHelperEncoder) EncTextMarshal(iv encoding.TextMarshaler) {
 	bs, fnerr := iv.MarshalText()
 	bs, fnerr := iv.MarshalText()
-	f.e.marshal(bs, fnerr, false, c_UTF8)
+	f.e.marshal(bs, fnerr, false, cUTF8)
 }
 }
 // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
 // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
 func (f genHelperEncoder) EncJSONMarshal(iv jsonMarshaler) {
 func (f genHelperEncoder) EncJSONMarshal(iv jsonMarshaler) {
 	bs, fnerr := iv.MarshalJSON()
 	bs, fnerr := iv.MarshalJSON()
-	f.e.marshal(bs, fnerr, true, c_UTF8)
+	f.e.marshal(bs, fnerr, true, cUTF8)
 }
 }
 // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
 // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
 func (f genHelperEncoder) EncBinaryMarshal(iv encoding.BinaryMarshaler) {
 func (f genHelperEncoder) EncBinaryMarshal(iv encoding.BinaryMarshaler) {
 	bs, fnerr := iv.MarshalBinary()
 	bs, fnerr := iv.MarshalBinary()
-	f.e.marshal(bs, fnerr, false, c_RAW)
+	f.e.marshal(bs, fnerr, false, cRAW)
 }
 }
 // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
 // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
 func (f genHelperEncoder) EncRaw(iv Raw) {
 func (f genHelperEncoder) EncRaw(iv Raw) {

+ 49 - 48
codec/gen.go

@@ -129,10 +129,11 @@ const (
 )
 )
 
 
 var (
 var (
-	genAllTypesSamePkgErr  = errors.New("All types must be in the same package")
-	genExpectArrayOrMapErr = errors.New("unexpected type. Expecting array/map/slice")
-	genBase64enc           = base64.NewEncoding("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789__")
-	genQNameRegex          = regexp.MustCompile(`[A-Za-z_.]+`)
+	errGenAllTypesSamePkg  = errors.New("All types must be in the same package")
+	errGenExpectArrayOrMap = errors.New("unexpected type. Expecting array/map/slice")
+
+	genBase64enc  = base64.NewEncoding("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789__")
+	genQNameRegex = regexp.MustCompile(`[A-Za-z_.]+`)
 )
 )
 
 
 // genRunner holds some state used during a Gen run.
 // genRunner holds some state used during a Gen run.
@@ -170,7 +171,7 @@ type genRunner struct {
 // Gen will write a complete go file containing Selfer implementations for each
 // Gen will write a complete go file containing Selfer implementations for each
 // type passed. All the types must be in the same package.
 // type passed. All the types must be in the same package.
 //
 //
-// Library users: DO NOT USE IT DIRECTLY. IT WILL CHANGE CONTINOUSLY WITHOUT NOTICE.
+// Library users: DO NOT USE IT DIRECTLY. IT WILL CHANGE CONTINUOUSLY WITHOUT NOTICE.
 func Gen(w io.Writer, buildTags, pkgName, uid string, noExtensions bool,
 func Gen(w io.Writer, buildTags, pkgName, uid string, noExtensions bool,
 	ti *TypeInfos, typ ...reflect.Type) {
 	ti *TypeInfos, typ ...reflect.Type) {
 	// All types passed to this method do not have a codec.Selfer method implemented directly.
 	// All types passed to this method do not have a codec.Selfer method implemented directly.
@@ -209,7 +210,7 @@ func Gen(w io.Writer, buildTags, pkgName, uid string, noExtensions bool,
 	for _, t := range typ {
 	for _, t := range typ {
 		// fmt.Printf("###########: PkgPath: '%v', Name: '%s'\n", genImportPath(t), t.Name())
 		// fmt.Printf("###########: PkgPath: '%v', Name: '%s'\n", genImportPath(t), t.Name())
 		if genImportPath(t) != x.bp {
 		if genImportPath(t) != x.bp {
-			panic(genAllTypesSamePkgErr)
+			panic(errGenAllTypesSamePkg)
 		}
 		}
 		x.genRefPkgs(t)
 		x.genRefPkgs(t)
 	}
 	}
@@ -231,7 +232,7 @@ func Gen(w io.Writer, buildTags, pkgName, uid string, noExtensions bool,
 	}
 	}
 	// use a sorted set of im keys, so that we can get consistent output
 	// use a sorted set of im keys, so that we can get consistent output
 	imKeys := make([]string, 0, len(x.im))
 	imKeys := make([]string, 0, len(x.im))
-	for k, _ := range x.im {
+	for k := range x.im {
 		imKeys = append(imKeys, k)
 		imKeys = append(imKeys, k)
 	}
 	}
 	sort.Strings(imKeys)
 	sort.Strings(imKeys)
@@ -249,21 +250,21 @@ func Gen(w io.Writer, buildTags, pkgName, uid string, noExtensions bool,
 
 
 	x.line("const (")
 	x.line("const (")
 	x.linef("// ----- content types ----")
 	x.linef("// ----- content types ----")
-	x.linef("codecSelferC_UTF8%s = %v", x.xs, int64(c_UTF8))
-	x.linef("codecSelferC_RAW%s = %v", x.xs, int64(c_RAW))
+	x.linef("codecSelferCcUTF8%s = %v", x.xs, int64(cUTF8))
+	x.linef("codecSelferCcRAW%s = %v", x.xs, int64(cRAW))
 	x.linef("// ----- value types used ----")
 	x.linef("// ----- value types used ----")
 	x.linef("codecSelferValueTypeArray%s = %v", x.xs, int64(valueTypeArray))
 	x.linef("codecSelferValueTypeArray%s = %v", x.xs, int64(valueTypeArray))
 	x.linef("codecSelferValueTypeMap%s = %v", x.xs, int64(valueTypeMap))
 	x.linef("codecSelferValueTypeMap%s = %v", x.xs, int64(valueTypeMap))
 	x.linef("// ----- containerStateValues ----")
 	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.linef("codecSelferKcontainerMapKey%s = %v", x.xs, int64(containerMapKey))
+	x.linef("codecSelferKcontainerMapValue%s = %v", x.xs, int64(containerMapValue))
+	x.linef("codecSelferKcontainerMapEnd%s = %v", x.xs, int64(containerMapEnd))
+	x.linef("codecSelferKcontainerArrayElem%s = %v", x.xs, int64(containerArrayElem))
+	x.linef("codecSelferKcontainerArrayEnd%s = %v", x.xs, int64(containerArrayEnd))
 	x.line(")")
 	x.line(")")
 	x.line("var (")
 	x.line("var (")
 	x.line("codecSelferBitsize" + x.xs + " = uint8(reflect.TypeOf(uint(0)).Bits())")
 	x.line("codecSelferBitsize" + x.xs + " = uint8(reflect.TypeOf(uint(0)).Bits())")
-	x.line("codecSelferOnlyMapOrArrayEncodeToStructErr" + x.xs + " = errors.New(`only encoded map or array can be decoded into a struct`)")
+	x.line("errCodecSelferOnlyMapOrArrayEncodeToStruct" + x.xs + " = errors.New(`only encoded map or array can be decoded into a struct`)")
 	x.line(")")
 	x.line(")")
 	x.line("")
 	x.line("")
 
 
@@ -320,7 +321,7 @@ func Gen(w io.Writer, buildTags, pkgName, uid string, noExtensions bool,
 		case reflect.Map:
 		case reflect.Map:
 			x.encMapFallback("v", t)
 			x.encMapFallback("v", t)
 		default:
 		default:
-			panic(genExpectArrayOrMapErr)
+			panic(errGenExpectArrayOrMap)
 		}
 		}
 		x.line("}")
 		x.line("}")
 		x.line("")
 		x.line("")
@@ -335,7 +336,7 @@ func Gen(w io.Writer, buildTags, pkgName, uid string, noExtensions bool,
 		case reflect.Map:
 		case reflect.Map:
 			x.decMapFallback("v", rtid, t)
 			x.decMapFallback("v", rtid, t)
 		default:
 		default:
-			panic(genExpectArrayOrMapErr)
+			panic(errGenExpectArrayOrMap)
 		}
 		}
 		x.line("}")
 		x.line("}")
 		x.line("")
 		x.line("")
@@ -757,7 +758,7 @@ func (x *genRunner) enc(varname string, t reflect.Type) {
 	case reflect.Bool:
 	case reflect.Bool:
 		x.line("r.EncodeBool(bool(" + varname + "))")
 		x.line("r.EncodeBool(bool(" + varname + "))")
 	case reflect.String:
 	case reflect.String:
-		x.line("r.EncodeString(codecSelferC_UTF8" + x.xs + ", string(" + varname + "))")
+		x.line("r.EncodeString(codecSelferCcUTF8" + x.xs + ", string(" + varname + "))")
 	case reflect.Chan:
 	case reflect.Chan:
 		x.xtraSM(varname, true, t)
 		x.xtraSM(varname, true, t)
 		// x.encListFallback(varname, rtid, t)
 		// x.encListFallback(varname, rtid, t)
@@ -771,7 +772,7 @@ func (x *genRunner) enc(varname string, t reflect.Type) {
 		// - if elements are primitives or Selfers, call dedicated function on each member.
 		// - if elements are primitives or Selfers, call dedicated function on each member.
 		// - else call Encoder.encode(XXX) on it.
 		// - else call Encoder.encode(XXX) on it.
 		if rtid == uint8SliceTypId {
 		if rtid == uint8SliceTypId {
-			x.line("r.EncodeStringBytes(codecSelferC_RAW" + x.xs + ", []byte(" + varname + "))")
+			x.line("r.EncodeStringBytes(codecSelferCcRAW" + x.xs + ", []byte(" + varname + "))")
 		} else if fastpathAV.index(rtid) != -1 {
 		} else if fastpathAV.index(rtid) != -1 {
 			g := x.newGenV(t)
 			g := x.newGenV(t)
 			x.line("z.F." + g.MethodNamePfx("Enc", false) + "V(" + varname + ", e)")
 			x.line("z.F." + g.MethodNamePfx("Enc", false) + "V(" + varname + ", e)")
@@ -821,7 +822,7 @@ func (x *genRunner) encZero(t reflect.Type) {
 	case reflect.Bool:
 	case reflect.Bool:
 		x.line("r.EncodeBool(false)")
 		x.line("r.EncodeBool(false)")
 	case reflect.String:
 	case reflect.String:
-		x.line("r.EncodeString(codecSelferC_UTF8" + x.xs + `, "")`)
+		x.line("r.EncodeString(codecSelferCcUTF8" + x.xs + `, "")`)
 	default:
 	default:
 		x.line("r.EncodeNil()")
 		x.line("r.EncodeNil()")
 	}
 	}
@@ -950,9 +951,9 @@ func (x *genRunner) encStruct(varname string, rtid uintptr, t reflect.Type) {
 		x.linef("if %s || %s {", ti2arrayvar, struct2arrvar) // if ti.toArray
 		x.linef("if %s || %s {", ti2arrayvar, struct2arrvar) // if ti.toArray
 		if labelUsed {
 		if labelUsed {
 			x.linef("if %s { r.WriteArrayElem(); r.EncodeNil() } else { ", isNilVarName)
 			x.linef("if %s { r.WriteArrayElem(); r.EncodeNil() } else { ", isNilVarName)
-			// x.linef("if %s { z.EncSendContainerState(codecSelfer_containerArrayElem%s); r.EncodeNil() } else { ", isNilVarName, x.xs)
+			// x.linef("if %s { z.EncSendContainerState(codecSelferKcontainerArrayElem%s); r.EncodeNil() } else { ", isNilVarName, x.xs)
 		}
 		}
-		x.line("r.WriteArrayElem()") // x.linef("z.EncSendContainerState(codecSelfer_containerArrayElem%s)", x.xs)
+		x.line("r.WriteArrayElem()") // x.linef("z.EncSendContainerState(codecSelferKcontainerArrayElem%s)", x.xs)
 		if si.omitEmpty {
 		if si.omitEmpty {
 			x.linef("if %s[%v] {", numfieldsvar, j)
 			x.linef("if %s[%v] {", numfieldsvar, j)
 		}
 		}
@@ -971,9 +972,9 @@ func (x *genRunner) encStruct(varname string, rtid uintptr, t reflect.Type) {
 		if si.omitEmpty {
 		if si.omitEmpty {
 			x.linef("if %s[%v] {", numfieldsvar, j)
 			x.linef("if %s[%v] {", numfieldsvar, j)
 		}
 		}
-		x.line("r.WriteMapElemKey()") // x.linef("z.EncSendContainerState(codecSelfer_containerMapKey%s)", x.xs)
-		x.line("r.EncodeString(codecSelferC_UTF8" + x.xs + ", string(\"" + si.encName + "\"))")
-		x.line("r.WriteMapElemValue()") // x.linef("z.EncSendContainerState(codecSelfer_containerMapValue%s)", x.xs)
+		x.line("r.WriteMapElemKey()") // x.linef("z.EncSendContainerState(codecSelferKcontainerMapKey%s)", x.xs)
+		x.line("r.EncodeString(codecSelferCcUTF8" + x.xs + ", `" + si.encName + "`)")
+		x.line("r.WriteMapElemValue()") // x.linef("z.EncSendContainerState(codecSelferKcontainerMapValue%s)", x.xs)
 		if labelUsed {
 		if labelUsed {
 			x.line("if " + isNilVarName + " { r.EncodeNil() } else { ")
 			x.line("if " + isNilVarName + " { r.EncodeNil() } else { ")
 			x.encVar(varname+"."+t2.Name, t2.Type)
 			x.encVar(varname+"."+t2.Name, t2.Type)
@@ -987,20 +988,20 @@ func (x *genRunner) encStruct(varname string, rtid uintptr, t reflect.Type) {
 		x.linef("} ") // end if/else ti.toArray
 		x.linef("} ") // end if/else ti.toArray
 	}
 	}
 	x.linef("if %s || %s {", ti2arrayvar, struct2arrvar) // if ti.toArray {
 	x.linef("if %s || %s {", ti2arrayvar, struct2arrvar) // if ti.toArray {
-	x.line("r.WriteArrayEnd()")                          // x.linef("z.EncSendContainerState(codecSelfer_containerArrayEnd%s)", x.xs)
+	x.line("r.WriteArrayEnd()")                          // x.linef("z.EncSendContainerState(codecSelferKcontainerArrayEnd%s)", x.xs)
 	x.line("} else {")
 	x.line("} else {")
-	x.line("r.WriteMapEnd()") // x.linef("z.EncSendContainerState(codecSelfer_containerMapEnd%s)", x.xs)
+	x.line("r.WriteMapEnd()") // x.linef("z.EncSendContainerState(codecSelferKcontainerMapEnd%s)", x.xs)
 	x.line("}")
 	x.line("}")
 
 
 }
 }
 
 
 func (x *genRunner) encListFallback(varname string, t reflect.Type) {
 func (x *genRunner) encListFallback(varname string, t reflect.Type) {
 	if t.AssignableTo(uint8SliceTyp) {
 	if t.AssignableTo(uint8SliceTyp) {
-		x.linef("r.EncodeStringBytes(codecSelferC_RAW%s, []byte(%s))", x.xs, varname)
+		x.linef("r.EncodeStringBytes(codecSelferCcRAW%s, []byte(%s))", x.xs, varname)
 		return
 		return
 	}
 	}
 	if t.Kind() == reflect.Array && t.Elem().Kind() == reflect.Uint8 {
 	if t.Kind() == reflect.Array && t.Elem().Kind() == reflect.Uint8 {
-		x.linef("r.EncodeStringBytes(codecSelferC_RAW%s, ((*[%d]byte)(%s))[:])", x.xs, t.Len(), varname)
+		x.linef("r.EncodeStringBytes(codecSelferCcRAW%s, ((*[%d]byte)(%s))[:])", x.xs, t.Len(), varname)
 		return
 		return
 	}
 	}
 	i := x.varsfx()
 	i := x.varsfx()
@@ -1008,16 +1009,16 @@ func (x *genRunner) encListFallback(varname string, t reflect.Type) {
 	x.line("r.WriteArrayStart(len(" + varname + "))")
 	x.line("r.WriteArrayStart(len(" + varname + "))")
 	if t.Kind() == reflect.Chan {
 	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("for %si%s, %si2%s := 0, len(%s); %si%s < %si2%s; %si%s++ {", g, i, g, i, varname, g, i, g, i, g, i)
-		x.line("r.WriteArrayElem()") // x.linef("z.EncSendContainerState(codecSelfer_containerArrayElem%s)", x.xs)
+		x.line("r.WriteArrayElem()") // x.linef("z.EncSendContainerState(codecSelferKcontainerArrayElem%s)", x.xs)
 		x.linef("%sv%s := <-%s", g, i, varname)
 		x.linef("%sv%s := <-%s", g, i, varname)
 	} else {
 	} else {
 		// x.linef("for %si%s, %sv%s := range %s {", genTempVarPfx, i, genTempVarPfx, i, 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("for _, %sv%s := range %s {", genTempVarPfx, i, varname)
-		x.line("r.WriteArrayElem()") // x.linef("z.EncSendContainerState(codecSelfer_containerArrayElem%s)", x.xs)
+		x.line("r.WriteArrayElem()") // x.linef("z.EncSendContainerState(codecSelferKcontainerArrayElem%s)", x.xs)
 	}
 	}
 	x.encVar(genTempVarPfx+"v"+i, t.Elem())
 	x.encVar(genTempVarPfx+"v"+i, t.Elem())
 	x.line("}")
 	x.line("}")
-	x.line("r.WriteArrayEnd()") // x.linef("z.EncSendContainerState(codecSelfer_containerArrayEnd%s)", x.xs)
+	x.line("r.WriteArrayEnd()") // x.linef("z.EncSendContainerState(codecSelferKcontainerArrayEnd%s)", x.xs)
 }
 }
 
 
 func (x *genRunner) encMapFallback(varname string, t reflect.Type) {
 func (x *genRunner) encMapFallback(varname string, t reflect.Type) {
@@ -1026,12 +1027,12 @@ func (x *genRunner) encMapFallback(varname string, t reflect.Type) {
 	x.line("r.WriteMapStart(len(" + varname + "))")
 	x.line("r.WriteMapStart(len(" + varname + "))")
 	x.linef("for %sk%s, %sv%s := range %s {", genTempVarPfx, i, genTempVarPfx, i, varname)
 	x.linef("for %sk%s, %sv%s := range %s {", genTempVarPfx, i, genTempVarPfx, i, varname)
 	// x.line("for " + genTempVarPfx + "k" + i + ", " + genTempVarPfx + "v" + i + " := range " + varname + " {")
 	// x.line("for " + genTempVarPfx + "k" + i + ", " + genTempVarPfx + "v" + i + " := range " + varname + " {")
-	x.line("r.WriteMapElemKey()") // f("z.EncSendContainerState(codecSelfer_containerMapKey%s)", x.xs)
+	x.line("r.WriteMapElemKey()") // f("z.EncSendContainerState(codecSelferKcontainerMapKey%s)", x.xs)
 	x.encVar(genTempVarPfx+"k"+i, t.Key())
 	x.encVar(genTempVarPfx+"k"+i, t.Key())
-	x.line("r.WriteMapElemValue()") // f("z.EncSendContainerState(codecSelfer_containerMapValue%s)", x.xs)
+	x.line("r.WriteMapElemValue()") // f("z.EncSendContainerState(codecSelferKcontainerMapValue%s)", x.xs)
 	x.encVar(genTempVarPfx+"v"+i, t.Elem())
 	x.encVar(genTempVarPfx+"v"+i, t.Elem())
 	x.line("}")
 	x.line("}")
-	x.line("r.WriteMapEnd()") // f("z.EncSendContainerState(codecSelfer_containerMapEnd%s)", x.xs)
+	x.line("r.WriteMapEnd()") // f("z.EncSendContainerState(codecSelferKcontainerMapEnd%s)", x.xs)
 }
 }
 
 
 func (x *genRunner) decVar(varname, decodedNilVarname string, t reflect.Type, canBeNil bool) {
 func (x *genRunner) decVar(varname, decodedNilVarname string, t reflect.Type, canBeNil bool) {
@@ -1499,15 +1500,15 @@ func (x *genRunner) decStructMap(varname, lenvarname string, rtid uintptr, t ref
 		x.linef("if %shl%s { if %sj%s >= %s { break }", tpfx, i, tpfx, i, lenvarname)
 		x.linef("if %shl%s { if %sj%s >= %s { break }", tpfx, i, tpfx, i, lenvarname)
 		x.line("} else { if r.CheckBreak() { break }; }")
 		x.line("} else { if r.CheckBreak() { break }; }")
 	}
 	}
-	x.line("r.ReadMapElemKey()") // f("z.DecSendContainerState(codecSelfer_containerMapKey%s)", x.xs)
+	x.line("r.ReadMapElemKey()") // f("z.DecSendContainerState(codecSelferKcontainerMapKey%s)", x.xs)
 	x.line(kName + "Slc = r.DecodeStringAsBytes()")
 	x.line(kName + "Slc = r.DecodeStringAsBytes()")
 	// let string be scoped to this loop alone, so it doesn't escape.
 	// let string be scoped to this loop alone, so it doesn't escape.
 	x.line(kName + " := string(" + kName + "Slc)")
 	x.line(kName + " := string(" + kName + "Slc)")
-	x.line("r.ReadMapElemValue()") // f("z.DecSendContainerState(codecSelfer_containerMapValue%s)", x.xs)
+	x.line("r.ReadMapElemValue()") // f("z.DecSendContainerState(codecSelferKcontainerMapValue%s)", x.xs)
 	x.decStructMapSwitch(kName, varname, rtid, t)
 	x.decStructMapSwitch(kName, varname, rtid, t)
 
 
 	x.line("} // end for " + tpfx + "j" + i)
 	x.line("} // end for " + tpfx + "j" + i)
-	x.line("r.ReadMapEnd()") // f("z.DecSendContainerState(codecSelfer_containerMapEnd%s)", x.xs)
+	x.line("r.ReadMapEnd()") // f("z.DecSendContainerState(codecSelferKcontainerMapEnd%s)", x.xs)
 }
 }
 
 
 func (x *genRunner) decStructArray(varname, lenvarname, breakString string, rtid uintptr, t reflect.Type) {
 func (x *genRunner) decStructArray(varname, lenvarname, breakString string, rtid uintptr, t reflect.Type) {
@@ -1545,8 +1546,8 @@ func (x *genRunner) decStructArray(varname, lenvarname, breakString string, rtid
 			tpfx, i, tpfx, i, tpfx, i,
 			tpfx, i, tpfx, i, tpfx, i,
 			tpfx, i, lenvarname, tpfx, i)
 			tpfx, i, lenvarname, tpfx, i)
 		x.linef("if %sb%s { r.ReadArrayEnd(); %s }", tpfx, i, breakString)
 		x.linef("if %sb%s { r.ReadArrayEnd(); %s }", tpfx, i, breakString)
-		// x.linef("if %sb%s { z.DecSendContainerState(codecSelfer_containerArrayEnd%s); %s }", tpfx, i, x.xs, breakString)
-		x.line("r.ReadArrayElem()") // f("z.DecSendContainerState(codecSelfer_containerArrayElem%s)", x.xs)
+		// x.linef("if %sb%s { z.DecSendContainerState(codecSelferKcontainerArrayEnd%s); %s }", tpfx, i, x.xs, breakString)
+		x.line("r.ReadArrayElem()") // f("z.DecSendContainerState(codecSelferKcontainerArrayElem%s)", x.xs)
 		x.decVar(varname+"."+t2.Name, "", t2.Type, true)
 		x.decVar(varname+"."+t2.Name, "", t2.Type, true)
 	}
 	}
 	// read remaining values and throw away.
 	// read remaining values and throw away.
@@ -1555,10 +1556,10 @@ func (x *genRunner) decStructArray(varname, lenvarname, breakString string, rtid
 		tpfx, i, tpfx, i, tpfx, i,
 		tpfx, i, tpfx, i, tpfx, i,
 		tpfx, i, lenvarname, tpfx, i)
 		tpfx, i, lenvarname, tpfx, i)
 	x.linef("if %sb%s { break }", tpfx, i)
 	x.linef("if %sb%s { break }", tpfx, i)
-	x.line("r.ReadArrayElem()") // f("z.DecSendContainerState(codecSelfer_containerArrayElem%s)", x.xs)
+	x.line("r.ReadArrayElem()") // f("z.DecSendContainerState(codecSelferKcontainerArrayElem%s)", x.xs)
 	x.linef(`z.DecStructFieldNotFound(%sj%s - 1, "")`, tpfx, i)
 	x.linef(`z.DecStructFieldNotFound(%sj%s - 1, "")`, tpfx, i)
 	x.line("}")
 	x.line("}")
-	x.line("r.ReadArrayEnd()") // f("z.DecSendContainerState(codecSelfer_containerArrayEnd%s)", x.xs)
+	x.line("r.ReadArrayEnd()") // f("z.DecSendContainerState(codecSelferKcontainerArrayEnd%s)", x.xs)
 }
 }
 
 
 func (x *genRunner) decStruct(varname string, rtid uintptr, t reflect.Type) {
 func (x *genRunner) decStruct(varname string, rtid uintptr, t reflect.Type) {
@@ -1568,7 +1569,7 @@ func (x *genRunner) decStruct(varname string, rtid uintptr, t reflect.Type) {
 	x.linef("if %sct%s == codecSelferValueTypeMap%s {", genTempVarPfx, i, x.xs)
 	x.linef("if %sct%s == codecSelferValueTypeMap%s {", genTempVarPfx, i, x.xs)
 	x.line(genTempVarPfx + "l" + i + " := r.ReadMapStart()")
 	x.line(genTempVarPfx + "l" + i + " := r.ReadMapStart()")
 	x.linef("if %sl%s == 0 {", genTempVarPfx, i)
 	x.linef("if %sl%s == 0 {", genTempVarPfx, i)
-	x.line("r.ReadMapEnd()") // f("z.DecSendContainerState(codecSelfer_containerMapEnd%s)", x.xs)
+	x.line("r.ReadMapEnd()") // f("z.DecSendContainerState(codecSelferKcontainerMapEnd%s)", x.xs)
 	if genUseOneFunctionForDecStructMap {
 	if genUseOneFunctionForDecStructMap {
 		x.line("} else { ")
 		x.line("} else { ")
 		x.linef("x.codecDecodeSelfFromMap(%sl%s, d)", genTempVarPfx, i)
 		x.linef("x.codecDecodeSelfFromMap(%sl%s, d)", genTempVarPfx, i)
@@ -1584,13 +1585,13 @@ func (x *genRunner) decStruct(varname string, rtid uintptr, t reflect.Type) {
 	x.linef("} else if %sct%s == codecSelferValueTypeArray%s {", genTempVarPfx, i, x.xs)
 	x.linef("} else if %sct%s == codecSelferValueTypeArray%s {", genTempVarPfx, i, x.xs)
 	x.line(genTempVarPfx + "l" + i + " := r.ReadArrayStart()")
 	x.line(genTempVarPfx + "l" + i + " := r.ReadArrayStart()")
 	x.linef("if %sl%s == 0 {", genTempVarPfx, i)
 	x.linef("if %sl%s == 0 {", genTempVarPfx, i)
-	x.line("r.ReadArrayEnd()") // f("z.DecSendContainerState(codecSelfer_containerArrayEnd%s)", x.xs)
+	x.line("r.ReadArrayEnd()") // f("z.DecSendContainerState(codecSelferKcontainerArrayEnd%s)", x.xs)
 	x.line("} else { ")
 	x.line("} else { ")
 	x.linef("x.codecDecodeSelfFromArray(%sl%s, d)", genTempVarPfx, i)
 	x.linef("x.codecDecodeSelfFromArray(%sl%s, d)", genTempVarPfx, i)
 	x.line("}")
 	x.line("}")
 	// else panic
 	// else panic
 	x.line("} else { ")
 	x.line("} else { ")
-	x.line("panic(codecSelferOnlyMapOrArrayEncodeToStructErr" + x.xs + ")")
+	x.line("panic(errCodecSelferOnlyMapOrArrayEncodeToStruct" + x.xs + ")")
 	x.line("} ")
 	x.line("} ")
 }
 }
 
 
@@ -1800,8 +1801,8 @@ func genInternalZeroValue(s string) string {
 
 
 var genInternalNonZeroValueIdx [5]uint64
 var genInternalNonZeroValueIdx [5]uint64
 var genInternalNonZeroValueStrs = [2][5]string{
 var genInternalNonZeroValueStrs = [2][5]string{
-	[5]string{`"string-is-an-interface"`, "true", `"some-string"`, "11.1", "33"},
-	[5]string{`"string-is-an-interface-2"`, "true", `"some-string-2"`, "22.2", "44"},
+	{`"string-is-an-interface"`, "true", `"some-string"`, "11.1", "33"},
+	{`"string-is-an-interface-2"`, "true", `"some-string-2"`, "22.2", "44"},
 }
 }
 
 
 func genInternalNonZeroValue(s string) string {
 func genInternalNonZeroValue(s string) string {
@@ -1831,7 +1832,7 @@ func genInternalEncCommandAsString(s string, vname string) string {
 	case "int", "int8", "int16", "int32", "int64":
 	case "int", "int8", "int16", "int32", "int64":
 		return "ee.EncodeInt(int64(" + vname + "))"
 		return "ee.EncodeInt(int64(" + vname + "))"
 	case "string":
 	case "string":
-		return "ee.EncodeString(c_UTF8, " + vname + ")"
+		return "ee.EncodeString(cUTF8, " + vname + ")"
 	case "float32":
 	case "float32":
 		return "ee.EncodeFloat32(" + vname + ")"
 		return "ee.EncodeFloat32(" + vname + ")"
 	case "float64":
 	case "float64":

+ 23 - 23
codec/helper.go

@@ -161,12 +161,12 @@ func init() {
 type charEncoding uint8
 type charEncoding uint8
 
 
 const (
 const (
-	c_RAW charEncoding = iota
-	c_UTF8
-	c_UTF16LE
-	c_UTF16BE
-	c_UTF32LE
-	c_UTF32BE
+	cRAW charEncoding = iota
+	cUTF8
+	cUTF16LE
+	cUTF16BE
+	cUTF32LE
+	cUTF32BE
 )
 )
 
 
 // valueType is the stream type
 // valueType is the stream type
@@ -332,7 +332,7 @@ var (
 
 
 	chkOvf checkOverflow
 	chkOvf checkOverflow
 
 
-	noFieldNameToStructFieldInfoErr = errors.New("no field name passed to parseStructFieldInfo")
+	errNoFieldNameToStructFieldInfo = errors.New("no field name passed to parseStructFieldInfo")
 )
 )
 
 
 var defTypeInfos = NewTypeInfos([]string{"codec", "json"})
 var defTypeInfos = NewTypeInfos([]string{"codec", "json"})
@@ -388,9 +388,9 @@ type MapBySlice interface {
 	MapBySlice()
 	MapBySlice()
 }
 }
 
 
-// WARNING: DO NOT USE DIRECTLY. EXPORTED FOR GODOC BENEFIT. WILL BE REMOVED.
-//
 // BasicHandle encapsulates the common options and extension functions.
 // BasicHandle encapsulates the common options and extension functions.
+//
+// Deprecated: DO NOT USE DIRECTLY. EXPORTED FOR GODOC BENEFIT. WILL BE REMOVED.
 type BasicHandle struct {
 type BasicHandle struct {
 	// TypeInfos is used to get the type info for any type.
 	// TypeInfos is used to get the type info for any type.
 	//
 	//
@@ -545,31 +545,31 @@ func (x *setExtWrapper) UpdateExt(dest interface{}, v interface{}) {
 
 
 type binaryEncodingType struct{}
 type binaryEncodingType struct{}
 
 
-func (_ binaryEncodingType) isBinary() bool { return true }
+func (binaryEncodingType) isBinary() bool { return true }
 
 
 type textEncodingType struct{}
 type textEncodingType struct{}
 
 
-func (_ textEncodingType) isBinary() bool { return false }
+func (textEncodingType) isBinary() bool { return false }
 
 
 // noBuiltInTypes is embedded into many types which do not support builtins
 // noBuiltInTypes is embedded into many types which do not support builtins
 // e.g. msgpack, simple, cbor.
 // e.g. msgpack, simple, cbor.
 
 
 type noBuiltInTypeChecker struct{}
 type noBuiltInTypeChecker struct{}
 
 
-func (_ noBuiltInTypeChecker) IsBuiltinType(rt uintptr) bool { return false }
+func (noBuiltInTypeChecker) IsBuiltinType(rt uintptr) bool { return false }
 
 
 type noBuiltInTypes struct{ noBuiltInTypeChecker }
 type noBuiltInTypes struct{ noBuiltInTypeChecker }
 
 
-func (_ noBuiltInTypes) EncodeBuiltin(rt uintptr, v interface{}) {}
-func (_ noBuiltInTypes) DecodeBuiltin(rt uintptr, v interface{}) {}
+func (noBuiltInTypes) EncodeBuiltin(rt uintptr, v interface{}) {}
+func (noBuiltInTypes) DecodeBuiltin(rt uintptr, v interface{}) {}
 
 
 // type noStreamingCodec struct{}
 // type noStreamingCodec struct{}
-// func (_ noStreamingCodec) CheckBreak() bool { return false }
-// func (_ noStreamingCodec) hasElemSeparators() bool { return false }
+// func (noStreamingCodec) CheckBreak() bool { return false }
+// func (noStreamingCodec) hasElemSeparators() bool { return false }
 
 
 type noElemSeparators struct{}
 type noElemSeparators struct{}
 
 
-func (_ noElemSeparators) hasElemSeparators() (v bool) { return }
+func (noElemSeparators) hasElemSeparators() (v bool) { return }
 
 
 // bigenHelper.
 // bigenHelper.
 // Users must already slice the x completely, because we will not reslice.
 // Users must already slice the x completely, because we will not reslice.
@@ -709,7 +709,7 @@ func (si *structFieldInfo) field(v reflect.Value, update bool) (rv2 reflect.Valu
 
 
 func parseStructFieldInfo(fname string, stag string) *structFieldInfo {
 func parseStructFieldInfo(fname string, stag string) *structFieldInfo {
 	// if fname == "" {
 	// if fname == "" {
-	// 	panic(noFieldNameToStructFieldInfoErr)
+	// 	panic(errNoFieldNameToStructFieldInfo)
 	// }
 	// }
 	si := structFieldInfo{
 	si := structFieldInfo{
 		encName: fname,
 		encName: fname,
@@ -1128,7 +1128,7 @@ LOOP:
 		}
 		}
 
 
 		if f.Name == "" {
 		if f.Name == "" {
-			panic(noFieldNameToStructFieldInfoErr)
+			panic(errNoFieldNameToStructFieldInfo)
 		}
 		}
 
 
 		pv.fNames = append(pv.fNames, f.Name)
 		pv.fNames = append(pv.fNames, f.Name)
@@ -1545,14 +1545,14 @@ func (c *codecFner) get(rt reflect.Type, checkFastpath, checkCodecSelfer bool) (
 // these functions must be inlinable, and not call anybody
 // these functions must be inlinable, and not call anybody
 type checkOverflow struct{}
 type checkOverflow struct{}
 
 
-func (_ checkOverflow) Float32(f float64) (overflow bool) {
+func (checkOverflow) Float32(f float64) (overflow bool) {
 	if f < 0 {
 	if f < 0 {
 		f = -f
 		f = -f
 	}
 	}
 	return math.MaxFloat32 < f && f <= math.MaxFloat64
 	return math.MaxFloat32 < f && f <= math.MaxFloat64
 }
 }
 
 
-func (_ checkOverflow) Uint(v uint64, bitsize uint8) (overflow bool) {
+func (checkOverflow) Uint(v uint64, bitsize uint8) (overflow bool) {
 	if bitsize == 0 || bitsize >= 64 || v == 0 {
 	if bitsize == 0 || bitsize >= 64 || v == 0 {
 		return
 		return
 	}
 	}
@@ -1562,7 +1562,7 @@ func (_ checkOverflow) Uint(v uint64, bitsize uint8) (overflow bool) {
 	return
 	return
 }
 }
 
 
-func (_ checkOverflow) Int(v int64, bitsize uint8) (overflow bool) {
+func (checkOverflow) Int(v int64, bitsize uint8) (overflow bool) {
 	if bitsize == 0 || bitsize >= 64 || v == 0 {
 	if bitsize == 0 || bitsize >= 64 || v == 0 {
 		return
 		return
 	}
 	}
@@ -1572,7 +1572,7 @@ func (_ checkOverflow) Int(v int64, bitsize uint8) (overflow bool) {
 	return
 	return
 }
 }
 
 
-func (_ checkOverflow) SignedInt(v uint64) (i int64, overflow bool) {
+func (checkOverflow) SignedInt(v uint64) (i int64, overflow bool) {
 	//e.g. -127 to 128 for int8
 	//e.g. -127 to 128 for int8
 	pos := (v >> 63) == 0
 	pos := (v >> 63) == 0
 	ui2 := v & 0x7fffffffffffffff
 	ui2 := v & 0x7fffffffffffffff

+ 10 - 12
codec/helper_internal.go

@@ -48,9 +48,8 @@ func hIsEmptyValue(v reflect.Value, deref, checkStruct bool) bool {
 				return true
 				return true
 			}
 			}
 			return hIsEmptyValue(v.Elem(), deref, checkStruct)
 			return hIsEmptyValue(v.Elem(), deref, checkStruct)
-		} else {
-			return v.IsNil()
 		}
 		}
+		return v.IsNil()
 	case reflect.Struct:
 	case reflect.Struct:
 		if !checkStruct {
 		if !checkStruct {
 			return false
 			return false
@@ -97,21 +96,20 @@ func halfFloatToFloatBits(yy uint16) (d uint32) {
 	if e == 0 {
 	if e == 0 {
 		if m == 0 { // plu or minus 0
 		if m == 0 { // plu or minus 0
 			return s << 31
 			return s << 31
-		} else { // Denormalized number -- renormalize it
-			for (m & 0x00000400) == 0 {
-				m <<= 1
-				e -= 1
-			}
-			e += 1
-			const zz uint32 = 0x0400
-			m &= ^zz
 		}
 		}
+		// Denormalized number -- renormalize it
+		for (m & 0x00000400) == 0 {
+			m <<= 1
+			e -= 1
+		}
+		e += 1
+		const zz uint32 = 0x0400
+		m &= ^zz
 	} else if e == 31 {
 	} else if e == 31 {
 		if m == 0 { // Inf
 		if m == 0 { // Inf
 			return (s << 31) | 0x7f800000
 			return (s << 31) | 0x7f800000
-		} else { // NaN
-			return (s << 31) | 0x7f800000 | (m << 13)
 		}
 		}
+		return (s << 31) | 0x7f800000 | (m << 13) // NaN
 	}
 	}
 	e = e + (127 - 15)
 	e = e + (127 - 15)
 	m = m << 13
 	m = m << 13

+ 3 - 3
codec/helper_not_unsafe.go

@@ -72,8 +72,8 @@ func rv2rtid(rv reflect.Value) uintptr {
 // --------------------------
 // --------------------------
 // type ptrToRvMap struct{}
 // type ptrToRvMap struct{}
 
 
-// func (_ *ptrToRvMap) init() {}
-// func (_ *ptrToRvMap) get(i interface{}) reflect.Value {
+// func (*ptrToRvMap) init() {}
+// func (*ptrToRvMap) get(i interface{}) reflect.Value {
 // 	return reflect.ValueOf(i).Elem()
 // 	return reflect.ValueOf(i).Elem()
 // }
 // }
 
 
@@ -166,7 +166,7 @@ func (e *Encoder) kBool(f *codecFnInfo, rv reflect.Value) {
 }
 }
 
 
 func (e *Encoder) kString(f *codecFnInfo, rv reflect.Value) {
 func (e *Encoder) kString(f *codecFnInfo, rv reflect.Value) {
-	e.e.EncodeString(c_UTF8, rv.String())
+	e.e.EncodeString(cUTF8, rv.String())
 }
 }
 
 
 func (e *Encoder) kFloat64(f *codecFnInfo, rv reflect.Value) {
 func (e *Encoder) kFloat64(f *codecFnInfo, rv reflect.Value) {

+ 1 - 1
codec/helper_unsafe.go

@@ -226,7 +226,7 @@ func (e *Encoder) kBool(f *codecFnInfo, rv reflect.Value) {
 
 
 func (e *Encoder) kString(f *codecFnInfo, rv reflect.Value) {
 func (e *Encoder) kString(f *codecFnInfo, rv reflect.Value) {
 	v := (*unsafeReflectValue)(unsafe.Pointer(&rv))
 	v := (*unsafeReflectValue)(unsafe.Pointer(&rv))
-	e.e.EncodeString(c_UTF8, *(*string)(v.ptr))
+	e.e.EncodeString(cUTF8, *(*string)(v.ptr))
 }
 }
 
 
 func (e *Encoder) kFloat64(f *codecFnInfo, rv reflect.Value) {
 func (e *Encoder) kFloat64(f *codecFnInfo, rv reflect.Value) {

+ 16 - 14
codec/json.go

@@ -375,11 +375,12 @@ func (e *jsonEncDriver) EncodeSymbol(v string) {
 
 
 func (e *jsonEncDriver) EncodeStringBytes(c charEncoding, v []byte) {
 func (e *jsonEncDriver) EncodeStringBytes(c charEncoding, v []byte) {
 	// if encoding raw bytes and RawBytesExt is configured, use it to encode
 	// 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 {
+	if c == cRAW {
+		if e.se.i != nil {
+			e.EncodeExt(v, 0, &e.se, e.e)
+			return
+		}
+
 		slen := base64.StdEncoding.EncodedLen(len(v))
 		slen := base64.StdEncoding.EncodedLen(len(v))
 		if cap(e.bs) >= slen {
 		if cap(e.bs) >= slen {
 			e.bs = e.bs[:slen]
 			e.bs = e.bs[:slen]
@@ -636,7 +637,7 @@ func (d *jsonDecDriver) TryDecodeAsNil() bool {
 	// TODO: we shouldn't try to see if "null" was here, right?
 	// TODO: we shouldn't try to see if "null" was here, right?
 	// only "null" denotes a nil
 	// only "null" denotes a nil
 	if d.tok == 'n' {
 	if d.tok == 'n' {
-		d.readLit(3, jsonLitNull+1) // ull
+		d.readLit(3, jsonLitNull+1) // (n)ull
 		return true
 		return true
 	}
 	}
 	return false
 	return false
@@ -652,10 +653,10 @@ func (d *jsonDecDriver) DecodeBool() (v bool) {
 	}
 	}
 	switch d.tok {
 	switch d.tok {
 	case 'f':
 	case 'f':
-		d.readLit(4, jsonLitFalse+1) // alse
+		d.readLit(4, jsonLitFalse+1) // (f)alse
 		// v = false
 		// v = false
 	case 't':
 	case 't':
-		d.readLit(3, jsonLitTrue+1) // rue
+		d.readLit(3, jsonLitTrue+1) // (t)rue
 		v = true
 		v = true
 	default:
 	default:
 		d.d.errorf("json: decode bool: got first char %c", d.tok)
 		d.d.errorf("json: decode bool: got first char %c", d.tok)
@@ -808,15 +809,15 @@ func (d *jsonDecDriver) appendStringAsBytes() {
 		// handle non-string scalar: null, true, false or a number
 		// handle non-string scalar: null, true, false or a number
 		switch d.tok {
 		switch d.tok {
 		case 'n':
 		case 'n':
-			d.readLit(3, jsonLitNull+1) // ull
+			d.readLit(3, jsonLitNull+1) // (n)ull
 			d.bs = d.bs[:0]
 			d.bs = d.bs[:0]
 			d.fnull = true
 			d.fnull = true
 		case 'f':
 		case 'f':
-			d.readLit(4, jsonLitFalse+1) // alse
+			d.readLit(4, jsonLitFalse+1) // (f)alse
 			d.bs = d.bs[:5]
 			d.bs = d.bs[:5]
 			copy(d.bs, "false")
 			copy(d.bs, "false")
 		case 't':
 		case 't':
-			d.readLit(3, jsonLitTrue+1) // rue
+			d.readLit(3, jsonLitTrue+1) // (t)rue
 			d.bs = d.bs[:4]
 			d.bs = d.bs[:4]
 			copy(d.bs, "true")
 			copy(d.bs, "true")
 		default:
 		default:
@@ -963,14 +964,14 @@ func (d *jsonDecDriver) DecodeNaked() {
 	}
 	}
 	switch d.tok {
 	switch d.tok {
 	case 'n':
 	case 'n':
-		d.readLit(3, jsonLitNull+1) // ull
+		d.readLit(3, jsonLitNull+1) // (n)ull
 		z.v = valueTypeNil
 		z.v = valueTypeNil
 	case 'f':
 	case 'f':
-		d.readLit(4, jsonLitFalse+1) // alse
+		d.readLit(4, jsonLitFalse+1) // (f)alse
 		z.v = valueTypeBool
 		z.v = valueTypeBool
 		z.b = false
 		z.b = false
 	case 't':
 	case 't':
-		d.readLit(3, jsonLitTrue+1) // rue
+		d.readLit(3, jsonLitTrue+1) // (t)rue
 		z.v = valueTypeBool
 		z.v = valueTypeBool
 		z.b = true
 		z.b = true
 	case '{':
 	case '{':
@@ -1093,6 +1094,7 @@ type JsonHandle struct {
 
 
 func (h *JsonHandle) hasElemSeparators() bool { return true }
 func (h *JsonHandle) hasElemSeparators() bool { return true }
 
 
+// SetInterfaceExt sets an extension
 func (h *JsonHandle) SetInterfaceExt(rt reflect.Type, tag uint64, ext InterfaceExt) (err error) {
 func (h *JsonHandle) SetInterfaceExt(rt reflect.Type, tag uint64, ext InterfaceExt) (err error) {
 	return h.SetExt(rt, tag, &setExtWrapper{i: ext})
 	return h.SetExt(rt, tag, &setExtWrapper{i: ext})
 }
 }

+ 2 - 2
codec/mammoth-test.go.tmpl

@@ -48,7 +48,7 @@ func doTestMammothSlices(t *testing.T, h Handle) {
 {{range $i, $e := .Values }}{{if not .Primitive }}{{if not .MapKey }}{{/*
 {{range $i, $e := .Values }}{{if not .Primitive }}{{if not .MapKey }}{{/*
 */}}
 */}}
     var v{{$i}}va [8]{{ .Elem }}
     var v{{$i}}va [8]{{ .Elem }}
-    for _, v := range [][]{{ .Elem }}{ nil, []{{ .Elem }}{}, []{{ .Elem }}{ {{ nonzerocmd .Elem }}, {{ zerocmd .Elem }}, {{ zerocmd .Elem }}, {{ nonzerocmd .Elem }} } } { {{/*
+    for _, v := range [][]{{ .Elem }}{ nil, {}, { {{ nonzerocmd .Elem }}, {{ zerocmd .Elem }}, {{ zerocmd .Elem }}, {{ nonzerocmd .Elem }} } } { {{/*
     // fmt.Printf(">>>> running mammoth slice v{{$i}}: %v\n", v)
     // fmt.Printf(">>>> running mammoth slice v{{$i}}: %v\n", v)
     //   - encode value to some []byte
     //   - encode value to some []byte
     //   - decode into a length-wise-equal []byte
     //   - decode into a length-wise-equal []byte
@@ -117,7 +117,7 @@ func doTestMammothSlices(t *testing.T, h Handle) {
 func doTestMammothMaps(t *testing.T, h Handle) {
 func doTestMammothMaps(t *testing.T, h Handle) {
 {{range $i, $e := .Values }}{{if not .Primitive }}{{if .MapKey }}{{/*
 {{range $i, $e := .Values }}{{if not .Primitive }}{{if .MapKey }}{{/*
 */}}
 */}}
-    for _, v := range []map[{{ .MapKey }}]{{ .Elem }}{ nil, map[{{ .MapKey }}]{{ .Elem }}{}, map[{{ .MapKey }}]{{ .Elem }}{ {{ nonzerocmd .MapKey }}:{{ zerocmd .Elem }} {{if ne "bool" .MapKey}}, {{ nonzerocmd .MapKey }}:{{ nonzerocmd .Elem }} {{end}} } } {
+    for _, v := range []map[{{ .MapKey }}]{{ .Elem }}{ nil, {}, { {{ nonzerocmd .MapKey }}:{{ zerocmd .Elem }} {{if ne "bool" .MapKey}}, {{ nonzerocmd .MapKey }}:{{ nonzerocmd .Elem }} {{end}} } } {
     // fmt.Printf(">>>> running mammoth map v{{$i}}: %v\n", v)
     // fmt.Printf(">>>> running mammoth map v{{$i}}: %v\n", v)
     var v{{$i}}v1, v{{$i}}v2 map[{{ .MapKey }}]{{ .Elem }}
     var v{{$i}}v1, v{{$i}}v2 map[{{ .MapKey }}]{{ .Elem }}
 	v{{$i}}v1 = v
 	v{{$i}}v1 = v

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 117 - 117
codec/mammoth2_codecgen_generated_test.go


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 112 - 112
codec/mammoth_generated_test.go


+ 8 - 6
codec/msgpack.go

@@ -200,7 +200,7 @@ func (e *msgpackEncDriver) EncodeExt(v interface{}, xtag uint64, ext Ext, _ *Enc
 		e.encodeExtPreamble(uint8(xtag), len(bs))
 		e.encodeExtPreamble(uint8(xtag), len(bs))
 		e.w.writeb(bs)
 		e.w.writeb(bs)
 	} else {
 	} else {
-		e.EncodeStringBytes(c_RAW, bs)
+		e.EncodeStringBytes(cRAW, bs)
 	}
 	}
 }
 }
 
 
@@ -244,7 +244,7 @@ func (e *msgpackEncDriver) WriteMapStart(length int) {
 
 
 func (e *msgpackEncDriver) EncodeString(c charEncoding, s string) {
 func (e *msgpackEncDriver) EncodeString(c charEncoding, s string) {
 	slen := len(s)
 	slen := len(s)
-	if c == c_RAW && e.h.WriteExt {
+	if c == cRAW && e.h.WriteExt {
 		e.writeContainerLen(msgpackContainerBin, slen)
 		e.writeContainerLen(msgpackContainerBin, slen)
 	} else {
 	} else {
 		e.writeContainerLen(msgpackContainerStr, slen)
 		e.writeContainerLen(msgpackContainerStr, slen)
@@ -255,12 +255,12 @@ func (e *msgpackEncDriver) EncodeString(c charEncoding, s string) {
 }
 }
 
 
 func (e *msgpackEncDriver) EncodeSymbol(v string) {
 func (e *msgpackEncDriver) EncodeSymbol(v string) {
-	e.EncodeString(c_UTF8, v)
+	e.EncodeString(cUTF8, v)
 }
 }
 
 
 func (e *msgpackEncDriver) EncodeStringBytes(c charEncoding, bs []byte) {
 func (e *msgpackEncDriver) EncodeStringBytes(c charEncoding, bs []byte) {
 	slen := len(bs)
 	slen := len(bs)
-	if c == c_RAW && e.h.WriteExt {
+	if c == cRAW && e.h.WriteExt {
 		e.writeContainerLen(msgpackContainerBin, slen)
 		e.writeContainerLen(msgpackContainerBin, slen)
 	} else {
 	} else {
 		e.writeContainerLen(msgpackContainerStr, slen)
 		e.writeContainerLen(msgpackContainerStr, slen)
@@ -643,9 +643,10 @@ func (d *msgpackDecDriver) ContainerType() (vt valueType) {
 		return valueTypeArray
 		return valueTypeArray
 	} else if bd == mpMap16 || bd == mpMap32 || (bd >= mpFixMapMin && bd <= mpFixMapMax) {
 	} else if bd == mpMap16 || bd == mpMap32 || (bd >= mpFixMapMin && bd <= mpFixMapMax) {
 		return valueTypeMap
 		return valueTypeMap
-	} else {
-		// d.d.errorf("isContainerType: unsupported parameter: %v", vt)
 	}
 	}
+	// else {
+	// d.d.errorf("isContainerType: unsupported parameter: %v", vt)
+	// }
 	return valueTypeUnset
 	return valueTypeUnset
 }
 }
 
 
@@ -788,6 +789,7 @@ type MsgpackHandle struct {
 	noElemSeparators
 	noElemSeparators
 }
 }
 
 
+// SetBytesExt sets an extension
 func (h *MsgpackHandle) SetBytesExt(rt reflect.Type, tag uint64, ext BytesExt) (err error) {
 func (h *MsgpackHandle) SetBytesExt(rt reflect.Type, tag uint64, ext BytesExt) (err error) {
 	return h.SetExt(rt, tag, &setExtWrapper{b: ext})
 	return h.SetExt(rt, tag, &setExtWrapper{b: ext})
 }
 }

+ 8 - 6
codec/simple.go

@@ -182,7 +182,7 @@ func (e *simpleEncDriver) EncodeString(c charEncoding, v string) {
 }
 }
 
 
 func (e *simpleEncDriver) EncodeSymbol(v string) {
 func (e *simpleEncDriver) EncodeSymbol(v string) {
-	e.EncodeString(c_UTF8, v)
+	e.EncodeString(cUTF8, v)
 }
 }
 
 
 func (e *simpleEncDriver) EncodeStringBytes(c charEncoding, v []byte) {
 func (e *simpleEncDriver) EncodeStringBytes(c charEncoding, v []byte) {
@@ -240,9 +240,10 @@ func (d *simpleDecDriver) ContainerType() (vt valueType) {
 	} else if d.bd == simpleVdMap || d.bd == simpleVdMap+1 ||
 	} else if d.bd == simpleVdMap || d.bd == simpleVdMap+1 ||
 		d.bd == simpleVdMap+2 || d.bd == simpleVdMap+3 || d.bd == simpleVdMap+4 {
 		d.bd == simpleVdMap+2 || d.bd == simpleVdMap+3 || d.bd == simpleVdMap+4 {
 		return valueTypeMap
 		return valueTypeMap
-	} else {
-		// d.d.errorf("isContainerType: unsupported parameter: %v", vt)
 	}
 	}
+	// else {
+	// d.d.errorf("isContainerType: unsupported parameter: %v", vt)
+	// }
 	return valueTypeUnset
 	return valueTypeUnset
 }
 }
 
 
@@ -570,7 +571,7 @@ func (d *simpleDecDriver) DecodeNaked() {
 //   - Integers (intXXX, uintXXX) are encoded in 1, 2, 4 or 8 bytes (plus a descriptor byte).
 //   - Integers (intXXX, uintXXX) are encoded in 1, 2, 4 or 8 bytes (plus a descriptor byte).
 //     There are positive (uintXXX and intXXX >= 0) and negative (intXXX < 0) integers.
 //     There are positive (uintXXX and intXXX >= 0) and negative (intXXX < 0) integers.
 //   - Floats are encoded in 4 or 8 bytes (plus a descriptor byte)
 //   - Floats are encoded in 4 or 8 bytes (plus a descriptor byte)
-//   - Lenght of containers (strings, bytes, array, map, extensions)
+//   - Length of containers (strings, bytes, array, map, extensions)
 //     are encoded in 0, 1, 2, 4 or 8 bytes.
 //     are encoded in 0, 1, 2, 4 or 8 bytes.
 //     Zero-length containers have no length encoded.
 //     Zero-length containers have no length encoded.
 //     For others, the number of bytes is given by pow(2, bd%3)
 //     For others, the number of bytes is given by pow(2, bd%3)
@@ -588,12 +589,13 @@ type SimpleHandle struct {
 	EncZeroValuesAsNil bool
 	EncZeroValuesAsNil bool
 }
 }
 
 
-func (h *SimpleHandle) hasElemSeparators() bool { return true } // as it implements Write(Map|Array)XXX
-
+// SetBytesExt sets an extension
 func (h *SimpleHandle) SetBytesExt(rt reflect.Type, tag uint64, ext BytesExt) (err error) {
 func (h *SimpleHandle) SetBytesExt(rt reflect.Type, tag uint64, ext BytesExt) (err error) {
 	return h.SetExt(rt, tag, &setExtWrapper{b: ext})
 	return h.SetExt(rt, tag, &setExtWrapper{b: ext})
 }
 }
 
 
+func (h *SimpleHandle) hasElemSeparators() bool { return true } // as it implements Write(Map|Array)XXX
+
 func (h *SimpleHandle) newEncDriver(e *Encoder) encDriver {
 func (h *SimpleHandle) newEncDriver(e *Encoder) encDriver {
 	return &simpleEncDriver{e: e, w: e.w, h: h}
 	return &simpleEncDriver{e: e, w: e.w, h: h}
 }
 }

+ 1 - 1
codec/time.go

@@ -176,7 +176,7 @@ func decodeTime(bs []byte) (tt time.Time, err error) {
 
 
 	i2 = i + 2
 	i2 = i + 2
 	tz = bigen.Uint16(bs[i:i2])
 	tz = bigen.Uint16(bs[i:i2])
-	i = i2
+	// i = i2
 	// sign extend sign bit into top 2 MSB (which were dst bits):
 	// sign extend sign bit into top 2 MSB (which were dst bits):
 	if tz&(1<<13) == 0 { // positive
 	if tz&(1<<13) == 0 { // positive
 		tz = tz & 0x3fff //clear 2 MSBs: dst bits
 		tz = tz & 0x3fff //clear 2 MSBs: dst bits

+ 1 - 1
codec/values_flex_test.go

@@ -52,7 +52,7 @@ func newTestStrucFlex(depth, n int, bench, useInterface, useStringKeyOnly bool)
 			22:  "twenty two",
 			22:  "twenty two",
 			-44: "minus forty four",
 			-44: "minus forty four",
 		},
 		},
-		Mbu64: map[bool]struct{}{false: struct{}{}, true: struct{}{}},
+		Mbu64: map[bool]struct{}{false: {}, true: {}},
 	}
 	}
 	populateTestStrucCommon(&ts.testStrucCommon, n, bench, useInterface, useStringKeyOnly)
 	populateTestStrucCommon(&ts.testStrucCommon, n, bench, useInterface, useStringKeyOnly)
 	if depth > 0 {
 	if depth > 0 {

+ 5 - 5
codec/xml.go

@@ -70,7 +70,7 @@ To handle namespaces:
         }
         }
      }
      }
 
 
-The structure below accomodates this:
+The structure below accommodates this:
 
 
   type typeInfo struct {
   type typeInfo struct {
     sfi []*structFieldInfo // sorted by encName
     sfi []*structFieldInfo // sorted by encName
@@ -134,7 +134,7 @@ At decode time, a structure containing the following is kept
   - all internal entities (<>&"' and others written in the document)
   - all internal entities (<>&"' and others written in the document)
 
 
 When decode starts, it parses XML namespace declarations and creates a map in the
 When decode starts, it parses XML namespace declarations and creates a map in the
-xmlDecDriver. While parsing, that map continously gets updated.
+xmlDecDriver. While parsing, that map continuously gets updated.
 The only problem happens when a namespace declaration happens on the node that it defines.
 The only problem happens when a namespace declaration happens on the node that it defines.
 e.g. <hn:name xmlns:hn="http://www.ugorji.net" >
 e.g. <hn:name xmlns:hn="http://www.ugorji.net" >
 To handle this, each Element must be fully parsed at a time,
 To handle this, each Element must be fully parsed at a time,
@@ -146,7 +146,7 @@ xmlns is a special attribute name.
   *We may decide later to allow user to use it e.g. you want to parse the xmlns mappings into a field.*
   *We may decide later to allow user to use it e.g. you want to parse the xmlns mappings into a field.*
 
 
 Number, bool, null, mapKey, etc can all be decoded from any xmlToken.
 Number, bool, null, mapKey, etc can all be decoded from any xmlToken.
-This accomodates map[int]string for example.
+This accommodates map[int]string for example.
 
 
 It should be possible to create a schema from the types,
 It should be possible to create a schema from the types,
 or vice versa (generate types from schema with appropriate tags).
 or vice versa (generate types from schema with appropriate tags).
@@ -181,7 +181,7 @@ Consequently, we cannot "DecodeNaked" into a map[string]interface{} (for example
 We have to "DecodeNaked" into something that resembles XML data.
 We have to "DecodeNaked" into something that resembles XML data.
 
 
 To support DecodeNaked (decode into nil interface{}), we have to define some "supporting" types:
 To support DecodeNaked (decode into nil interface{}), we have to define some "supporting" types:
-    type Name struct { // Prefered. Less allocations due to conversions.
+    type Name struct { // Preferred. Less allocations due to conversions.
       Local string
       Local string
       Space string
       Space string
     }
     }
@@ -222,7 +222,7 @@ intelligent accessor methods to extract information and for performance.
 // ------------------
 // ------------------
 
 
 Per XML spec and our default handling, white space is insignificant between elements,
 Per XML spec and our default handling, white space is insignificant between elements,
-specifically between parent-child or siblings. White space occuring alone between start
+specifically between parent-child or siblings. White space occurring alone between start
 and end element IS significant. However, if xml:space='preserve', then we 'preserve'
 and end element IS significant. However, if xml:space='preserve', then we 'preserve'
 all whitespace. This is more critical when doing a DecodeNaked, but MAY not be as critical
 all whitespace. This is more critical when doing a DecodeNaked, but MAY not be as critical
 when decoding into a typed value.
 when decoding into a typed value.

Kaikkia tiedostoja ei voida näyttää, sillä liian monta tiedostoa muuttui tässä diffissä