func (z *ioEncWriter) atEndOfEncode() {
	if z.fw != nil {
		if err := z.fw.Flush(); err != nil {
			panic(err)
		}
	}
}
func (z *ioEncWriter) writen5(b1, b2, b3, b4, b5 byte) {
z.b[0], z.b[1], z.b[2], z.b[3], z.b[4] = b1, b2, b3, b4, b5
if _, err := z.ww.Write(z.b[:5]); err != nil {
panic(err)
}
}
package codec
import (
	"bufio"
	"encoding"
	"errors"
	"fmt"
	"io"
	"reflect"
	"sort"
	"strconv"
	"sync"
	"time"
)
const defEncByteBufSize = 1 << 6  
var errEncoderNotInitialized = errors.New("Encoder not initialized")
type encWriter interface {
	writeb([]byte)
	writestr(string)
	writen1(byte)
	writen2(byte, byte)
	atEndOfEncode()
}
type encDriver interface {
	EncodeNil()
	EncodeInt(i int64)
	EncodeUint(i uint64)
	EncodeBool(b bool)
	EncodeFloat32(f float32)
	EncodeFloat64(f float64)
	EncodeRawExt(re *RawExt, e *Encoder)
	EncodeExt(v interface{}, xtag uint64, ext Ext, e *Encoder)
	EncodeString(c charEncoding, v string)
	EncodeStringBytes(c charEncoding, v []byte)
	EncodeTime(time.Time)
	WriteArrayStart(length int)
	WriteArrayElem()
	WriteArrayEnd()
	WriteMapStart(length int)
	WriteMapElemKey()
	WriteMapElemValue()
	WriteMapEnd()
	reset()
	atEndOfEncode()
}
type ioEncStringWriter interface {
	WriteString(s string) (n int, err error)
}
type encDriverAsis interface {
	EncodeAsis(v []byte)
}
type encDriverNoopContainerWriter struct{}
func (encDriverNoopContainerWriter) WriteArrayStart(length int) {}
func (encDriverNoopContainerWriter) WriteArrayElem()            {}
func (encDriverNoopContainerWriter) WriteArrayEnd()             {}
func (encDriverNoopContainerWriter) WriteMapStart(length int)   {}
func (encDriverNoopContainerWriter) WriteMapElemKey()           {}
func (encDriverNoopContainerWriter) WriteMapElemValue()         {}
func (encDriverNoopContainerWriter) WriteMapEnd()               {}
func (encDriverNoopContainerWriter) atEndOfEncode()             {}
type encDriverTrackContainerWriter struct {
	c containerState
}
func (e *encDriverTrackContainerWriter) WriteArrayStart(length int) { e.c = containerArrayStart }
func (e *encDriverTrackContainerWriter) WriteArrayElem()            { e.c = containerArrayElem }
func (e *encDriverTrackContainerWriter) WriteArrayEnd()             { e.c = containerArrayEnd }
func (e *encDriverTrackContainerWriter) WriteMapStart(length int)   { e.c = containerMapStart }
func (e *encDriverTrackContainerWriter) WriteMapElemKey()           { e.c = containerMapKey }
func (e *encDriverTrackContainerWriter) WriteMapElemValue()         { e.c = containerMapValue }
func (e *encDriverTrackContainerWriter) WriteMapEnd()               { e.c = containerMapEnd }
func (e *encDriverTrackContainerWriter) atEndOfEncode()             {}
type EncodeOptions struct {
	WriterBufferSize int
	ChanRecvTimeout time.Duration
	StructToArray bool
	Canonical bool
	CheckCircularRef bool
	RecursiveEmptyCheck bool
	Raw bool
}
type ioEncWriter struct {
	w  io.Writer
	ww io.Writer
	bw io.ByteWriter
	sw ioEncStringWriter
	fw ioFlusher
	b  [8]byte
}
func (z *ioEncWriter) WriteByte(b byte) (err error) {
	z.b[0] = b
	_, err = z.w.Write(z.b[:1])
	return
}
func (z *ioEncWriter) WriteString(s string) (n int, err error) {
	return z.w.Write(bytesView(s))
}
func (z *ioEncWriter) writeb(bs []byte) {
	if _, err := z.ww.Write(bs); err != nil {
		panic(err)
	}
}
func (z *ioEncWriter) writestr(s string) {
	if _, err := z.sw.WriteString(s); err != nil {
		panic(err)
	}
}
func (z *ioEncWriter) writen1(b byte) {
	if err := z.bw.WriteByte(b); err != nil {
		panic(err)
	}
}
func (z *ioEncWriter) writen2(b1, b2 byte) {
	var err error
	if err = z.bw.WriteByte(b1); err == nil {
		if err = z.bw.WriteByte(b2); err == nil {
			return
		}
	}
	panic(err)
}