Browse Source

codec: remove hasElemSeparators and elemsep flags

These are no longer used.
Ugorji Nwoke 6 years ago
parent
commit
fc17d02f6e
10 changed files with 24 additions and 31 deletions
  1. 1 1
      codec/binc.go
  2. 1 1
      codec/cbor.go
  3. 1 1
      codec/decode.go
  4. 8 17
      codec/encode.go
  5. 4 4
      codec/helper.go
  6. 3 2
      codec/json.go
  7. 1 1
      codec/msgpack.go
  8. 3 2
      codec/reader.go
  9. 1 1
      codec/simple.go
  10. 1 1
      codec/writer.go

+ 1 - 1
codec/binc.go

@@ -962,7 +962,7 @@ func (d *bincDecDriver) DecodeNaked() {
 type BincHandle struct {
 	BasicHandle
 	binaryEncodingType
-	noElemSeparators
+	// noElemSeparators
 
 	// AsSymbols defines what should be encoded as symbols.
 	//

+ 1 - 1
codec/cbor.go

@@ -841,7 +841,7 @@ func (d *cborDecDriver) DecodeNaked() {
 //   - Encoded Text (e.g. URL, regexp, base64, MIME Message), etc.
 type CborHandle struct {
 	binaryEncodingType
-	noElemSeparators
+	// noElemSeparators
 	BasicHandle
 
 	// IndefiniteLength=true, means that we encode using indefinitelength

+ 1 - 1
codec/decode.go

@@ -1423,7 +1423,7 @@ func newDecoder(h Handle) *Decoder {
 	if d.js {
 		d.jsms = jh.MapKeyAsString
 	}
-	d.esep = d.hh.hasElemSeparators()
+	// d.esep = d.hh.hasElemSeparators()
 	if d.h.InternString {
 		d.is = make(map[string]string, 32)
 	}

+ 8 - 17
codec/encode.go

@@ -44,7 +44,6 @@ type encDriver interface {
 
 	reset()
 	atEndOfEncode()
-	// encoder() *Encoder
 }
 
 type encDriverContainerTracker interface {
@@ -908,9 +907,15 @@ func newEncoder(h Handle) *Encoder {
 	}
 	// e.w = &e.encWr
 	e.hh = h
-	e.esep = h.hasElemSeparators()
+	// e.esep = h.hasElemSeparators()
 	e.e = e.hh.newEncDriver(e)
 	e.as, e.isas = e.e.(encDriverAsis)
+	e.be = e.hh.isBinary()
+	e.jenc = nil
+	_, e.js = e.hh.(*JsonHandle)
+	if e.js {
+		e.jenc = e.e.(*jsonEncDriver)
+	}
 	return e
 }
 
@@ -919,26 +924,12 @@ func (e *Encoder) w() *encWr {
 }
 
 func (e *Encoder) resetCommon() {
-	// e.w = &e.encWr
-	// if e.e == nil || e.hh.recreateEncDriver(e.e) {
-	// 	e.e = e.hh.newEncDriver(e)
-	// 	e.as, e.isas = e.e.(encDriverAsis)
-	// 	// e.cr, _ = e.e.(containerStateRecv)
-	// }
-
+	e.e.reset()
 	if e.ci == nil {
 		// e.ci = (set)(e.cidef[:0])
 	} else {
 		e.ci = e.ci[:0]
 	}
-
-	e.be = e.hh.isBinary()
-	e.jenc = nil
-	_, e.js = e.hh.(*JsonHandle)
-	if e.js {
-		e.jenc = e.e.(*jsonEncDriver)
-	}
-	e.e.reset()
 	e.c = 0
 	e.err = nil
 }

+ 4 - 4
codec/helper.go

@@ -1052,7 +1052,7 @@ type Handle interface {
 	newEncDriver(w *Encoder) encDriver
 	newDecDriver(r *Decoder) decDriver
 	isBinary() bool
-	hasElemSeparators() bool
+	// hasElemSeparators() bool
 	// IsBuiltinType(rtid uintptr) bool
 }
 
@@ -1209,10 +1209,10 @@ func (noBuiltInTypes) DecodeBuiltin(rt uintptr, v interface{}) {}
 // 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) recreateEncDriver(e encDriver) (v bool) { return }
+// func (noElemSeparators) hasElemSeparators() (v bool)            { return }
+// func (noElemSeparators) recreateEncDriver(e encDriver) (v bool) { return }
 
 // bigenHelper.
 // Users must already slice the x completely, because we will not reslice.

+ 3 - 2
codec/json.go

@@ -1433,8 +1433,9 @@ type JsonHandle struct {
 }
 
 // Name returns the name of the handle: json
-func (h *JsonHandle) Name() string            { return "json" }
-func (h *JsonHandle) hasElemSeparators() bool { return true }
+func (h *JsonHandle) Name() string { return "json" }
+
+// func (h *JsonHandle) hasElemSeparators() bool { return true }
 func (h *JsonHandle) typical() bool {
 	return h.Indent == 0 && !h.MapKeyAsString && h.IntegerAsString != 'A' && h.IntegerAsString != 'L'
 }

+ 1 - 1
codec/msgpack.go

@@ -941,7 +941,7 @@ func (d *msgpackDecDriver) decodeExtV(verifyTag bool, tag byte) (xtag byte, xbs
 //MsgpackHandle is a Handle for the Msgpack Schema-Free Encoding Format.
 type MsgpackHandle struct {
 	binaryEncodingType
-	noElemSeparators
+	// noElemSeparators
 	BasicHandle
 
 	// NoFixedNum says to output all signed integers as 2-bytes, never as 1-byte fixednum.

+ 3 - 2
codec/reader.go

@@ -1008,8 +1008,9 @@ func (z *bytesDecReader) stopTrack() (bs []byte) {
 // --------------
 
 type decRd struct {
-	esep     bool // has elem separators
-	mtr, str bool // whether maptype or slicetype are known types
+	// esep     bool // has elem separators
+	mtr bool // is maptype a known type?
+	str bool // is slicetype a known type?
 
 	be   bool // is binary encoding
 	js   bool // is json handle

+ 1 - 1
codec/simple.go

@@ -614,7 +614,7 @@ func (d *simpleDecDriver) DecodeNaked() {
 // The full spec will be published soon.
 type SimpleHandle struct {
 	binaryEncodingType
-	noElemSeparators
+	// noElemSeparators
 	BasicHandle
 	// EncZeroValuesAsNil says to encode zero values for numbers, bool, string, etc as nil
 	EncZeroValuesAsNil bool

+ 1 - 1
codec/writer.go

@@ -339,7 +339,7 @@ func (z *bytesEncAppender) reset(in []byte, out *[]byte) {
 // --------------------------------------------------
 
 type encWr struct {
-	esep  bool // whether it has elem separators
+	// esep  bool // whether it has elem separators
 	bytes bool // encoding to []byte
 	isas  bool // whether e.as != nil
 	js    bool // is json encoder?