Pārlūkot izejas kodu

codec: clean up comments in template files

Ugorji Nwoke 6 gadi atpakaļ
vecāks
revīzija
dffca6f219

+ 4 - 51
codec/fast-path.go.tmpl

@@ -177,15 +177,12 @@ func (fastpathT) {{ .MethodNamePfx "Enc" false }}V(v []{{ .Elem }}, e *Encoder)
 	e.arrayEnd()
 	e.arrayEnd()
 }
 }
 func (fastpathT) {{ .MethodNamePfx "EncAsMap" false }}V(v []{{ .Elem }}, e *Encoder) {
 func (fastpathT) {{ .MethodNamePfx "EncAsMap" false }}V(v []{{ .Elem }}, e *Encoder) {
-	{{/* if v == nil {
-		e.e.EncodeNil()
-    } else */ -}}
+	{{/* if v == nil { e.e.EncodeNil() } else */ -}}
 	if len(v)%2 == 1 {
 	if len(v)%2 == 1 {
 		e.errorf(fastpathMapBySliceErrMsg, len(v))
 		e.errorf(fastpathMapBySliceErrMsg, len(v))
 	} else {
 	} else {
 		e.mapStart(len(v) / 2)
 		e.mapStart(len(v) / 2)
 		for j := range v {
 		for j := range v {
-			{{/* e.mapElemKeyOrValue(uint8(j)%2) */ -}}
 			if j%2 == 0 {
 			if j%2 == 0 {
 				e.mapElemKey()
 				e.mapElemKey()
 			} else {
 			} else {
@@ -210,8 +207,8 @@ func (fastpathT) {{ .MethodNamePfx "Enc" false }}V(v map[{{ .MapKey }}]{{ .Elem
 		var mksv []byte = make([]byte, 0, len(v)*16) // temporary byte slice for the encoding
 		var mksv []byte = make([]byte, 0, len(v)*16) // temporary byte slice for the encoding
 		e2 := NewEncoderBytes(&mksv, e.hh)
 		e2 := NewEncoderBytes(&mksv, e.hh)
 		v2 := make([]bytesIntf, len(v))
 		v2 := make([]bytesIntf, len(v))
-		var i, l uint
-		var vp *bytesIntf {{/* put loop variables outside. seems currently needed for better perf */}}
+		var i, l uint {{/* put loop variables outside. seems currently needed for better perf */}}
+		var vp *bytesIntf
 		for k2 := range v {
 		for k2 := range v {
 			l = uint(len(mksv))
 			l = uint(len(mksv))
 			e2.MustEncode(k2)
 			e2.MustEncode(k2)
@@ -328,7 +325,6 @@ Slices can change if they
 - are settable (e.g. contained in an interface{})
 - are settable (e.g. contained in an interface{})
 */}}
 */}}
 func (d *Decoder) {{ .MethodNamePfx "fastpathDec" false }}R(f *codecFnInfo, rv reflect.Value) {
 func (d *Decoder) {{ .MethodNamePfx "fastpathDec" false }}R(f *codecFnInfo, rv reflect.Value) {
-	{{/* xdebugf("{{ .MethodNamePfx "fastpathDec" false }}R: f.seq: %v", f.seq) */ -}}
 	if f.seq != seqTypeArray && rv.Kind() == reflect.Ptr {
 	if f.seq != seqTypeArray && rv.Kind() == reflect.Ptr {
 		vp := rv2i(rv).(*[]{{ .Elem }})
 		vp := rv2i(rv).(*[]{{ .Elem }})
 		if v, changed := fastpathTV.{{ .MethodNamePfx "Dec" false }}Y(*vp, d); changed { *vp = v }
 		if v, changed := fastpathTV.{{ .MethodNamePfx "Dec" false }}Y(*vp, d); changed { *vp = v }
@@ -383,12 +379,6 @@ func (fastpathT) {{ .MethodNamePfx "Dec" false }}Y(v []{{ .Elem }}, d *Decoder)
 			changed = true
 			changed = true
 		} 
 		} 
 		slh.ElemContainerState(j)
 		slh.ElemContainerState(j)
-		{{/*
-		if d.d.TryDecodeAsNil() {
-			v[uint(j)] = {{ zerocmd .Elem }}
-		} else {
-			{{ if eq .Elem "interface{}" }}d.decode(&v[uint(j)]){{ else }}v[uint(j)] = {{ decmd .Elem }}{{ end }}
-		} */ -}}
 		{{ if eq .Elem "interface{}" }}d.decode(&v[uint(j)]){{ else }}v[uint(j)] = {{ decmd .Elem }}{{ end }}
 		{{ if eq .Elem "interface{}" }}d.decode(&v[uint(j)]){{ else }}v[uint(j)] = {{ decmd .Elem }}{{ end }}
 	}
 	}
 	if j < len(v) {
 	if j < len(v) {
@@ -418,12 +408,6 @@ func (fastpathT) {{ .MethodNamePfx "Dec" false }}N(v []{{ .Elem }}, d *Decoder)
 			return
 			return
 		} 
 		} 
 		slh.ElemContainerState(j)
 		slh.ElemContainerState(j)
-		{{/*
-		if d.d.TryDecodeAsNil() {
-			v[uint(j)] = {{ zerocmd .Elem }}
-		} else {
-			{{ if eq .Elem "interface{}" }}d.decode(&v[uint(j)]){{ else }}v[uint(j)] = {{ decmd .Elem }}{{ end }}
-		} */ -}}
 		{{ if eq .Elem "interface{}" -}}
 		{{ if eq .Elem "interface{}" -}}
 		d.decode(&v[uint(j)])
 		d.decode(&v[uint(j)])
 		{{- else -}}
 		{{- else -}}
@@ -487,30 +471,8 @@ func (f fastpathT) {{ .MethodNamePfx "Dec" false }}X(vp *map[{{ .MapKey }}]{{ .E
 		d.mapEnd()
 		d.mapEnd()
 	}
 	}
 }
 }
-{{/*
-func (f fastpathT) {{ .MethodNamePfx "Dec" false }}Y(v map[{{ .MapKey }}]{{ .Elem }}, d *Decoder) (_ map[{{ .MapKey }}]{{ .Elem }}, changed bool) {
-	containerLen := d.mapStart()
-	if v == nil {
-		v = make(map[{{ .MapKey }}]{{ .Elem }}, decInferLen(containerLen, d.h.MaxInitLen, {{ .Size }}))
-		changed = true
-	}
-	f.{{ .MethodNamePfx "Dec" false }}L(v, containerLen, d)
-	return v, changed
-}
-func (f fastpathT) {{ .MethodNamePfx "Dec" false }}N(v map[{{ .MapKey }}]{{ .Elem }}, d *Decoder) {
-	f.{{ .MethodNamePfx "Dec" false }}L(v, d.mapStart(), d)
-}
-*/ -}}
 func (fastpathT) {{ .MethodNamePfx "Dec" false }}L(v map[{{ .MapKey }}]{{ .Elem }}, containerLen int, d *Decoder) {
 func (fastpathT) {{ .MethodNamePfx "Dec" false }}L(v map[{{ .MapKey }}]{{ .Elem }}, containerLen int, d *Decoder) {
-	{{/* No need to check if containerLen == decContainerLenNil, as that is checked by R and L above
-	if containerLen == decContainerLenNil {
-		return
-	}
-	if containerLen == 0 {
-		d.mapEnd()
-		return
-	}
-	*/ -}}
+	{{/* No need to check if containerLen == decContainerLenNil, as that is checked by R and L above  */ -}}
 	{{if eq .Elem "interface{}" }}mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset
 	{{if eq .Elem "interface{}" }}mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset
     {{else if eq .Elem "bytes" "[]byte" }}mapGet := v != nil && !d.h.MapValueReset
     {{else if eq .Elem "bytes" "[]byte" }}mapGet := v != nil && !d.h.MapValueReset
     {{end -}}
     {{end -}}
@@ -525,12 +487,6 @@ func (fastpathT) {{ .MethodNamePfx "Dec" false }}L(v map[{{ .MapKey }}]{{ .Elem
 			mk = d.string(bv) {{/* // maps cannot have []byte as key. switch to string. */}}
 			mk = d.string(bv) {{/* // maps cannot have []byte as key. switch to string. */}}
 		}{{ else }}mk = {{ decmd .MapKey }}{{ end }}
 		}{{ else }}mk = {{ decmd .MapKey }}{{ end }}
 		d.mapElemValue()
 		d.mapElemValue()
-		{{/*
-		if d.d.TryDecodeAsNil() {
-			if v == nil {} else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = {{ zerocmd .Elem }} }
-			continue 
-		}
-		*/ -}}
 		{{ if eq .Elem "interface{}" "[]byte" "bytes" -}}
 		{{ if eq .Elem "interface{}" "[]byte" "bytes" -}}
 		if mapGet { mv = v[mk] } else { mv = nil }
 		if mapGet { mv = v[mk] } else { mv = nil }
 		{{ end -}}
 		{{ end -}}
@@ -543,8 +499,5 @@ func (fastpathT) {{ .MethodNamePfx "Dec" false }}L(v map[{{ .MapKey }}]{{ .Elem
 		{{ end -}}
 		{{ end -}}
 		if v != nil { v[mk] = mv }
 		if v != nil { v[mk] = mv }
 	}
 	}
-	{{- /*
-	d.mapEnd()
-	*/}}
 }
 }
 {{end}}{{end}}{{end}}
 {{end}}{{end}}{{end}}

+ 3 - 3
codec/gen-dec-map.go.tmpl

@@ -19,7 +19,7 @@ if z.DecBasicHandle().MapValueReset {
 if {{var "l"}} != 0 {
 if {{var "l"}} != 0 {
 	{{var "hl"}} := {{var "l"}} > 0 
 	{{var "hl"}} := {{var "l"}} > 0 
 	for {{var "j"}} := 0; ({{var "hl"}} && {{var "j"}} < {{var "l"}}) || !({{var "hl"}} || z.DecCheckBreak()); {{var "j"}}++ {
 	for {{var "j"}} := 0; ({{var "hl"}} && {{var "j"}} < {{var "l"}}) || !({{var "hl"}} || z.DecCheckBreak()); {{var "j"}}++ {
-	z.DecReadMapElemKey() {{/* z.DecSendContainerState(codecSelfer_containerMapKey{{ .Sfx }}) */}}
+	z.DecReadMapElemKey()
 	{{ $x := printf "%vmk%v" .TempVar .Rand }}{{ decLineVarK $x -}}
 	{{ $x := printf "%vmk%v" .TempVar .Rand }}{{ decLineVarK $x -}}
 	{{ if eq .KTyp "interface{}" }}{{/* // special case if a byte array. */ -}}
 	{{ if eq .KTyp "interface{}" }}{{/* // special case if a byte array. */ -}}
     if {{var "bv"}}, {{var "bok"}} := {{var "mk"}}.([]byte); {{var "bok"}} {
     if {{var "bv"}}, {{var "bok"}} := {{var "mk"}}.([]byte); {{var "bok"}} {
@@ -39,7 +39,7 @@ if {{var "l"}} != 0 {
         {{var "mv"}} = {{var "v"}}[{{var "mk"}}]
         {{var "mv"}} = {{var "v"}}[{{var "mk"}}]
         {{end -}}
         {{end -}}
 	} {{if not decElemKindImmutable}}else { {{var "mv"}} = {{decElemZero}} }{{end}}
 	} {{if not decElemKindImmutable}}else { {{var "mv"}} = {{decElemZero}} }{{end}}
-	z.DecReadMapElemValue() {{/* z.DecSendContainerState(codecSelfer_containerMapValue{{ .Sfx }}) */}}
+	z.DecReadMapElemValue()
 	{{var "mdn"}} = false
 	{{var "mdn"}} = false
 	{{ $x := printf "%vmv%v" .TempVar .Rand }}{{ $y := printf "%vmdn%v" .TempVar .Rand }}{{ decLineVar $x $y -}}
 	{{ $x := printf "%vmv%v" .TempVar .Rand }}{{ $y := printf "%vmdn%v" .TempVar .Rand }}{{ decLineVar $x $y -}}
 	if {{var "mdn"}} {
 	if {{var "mdn"}} {
@@ -49,5 +49,5 @@ if {{var "l"}} != 0 {
 	}
 	}
 }
 }
 } // else len==0: TODO: Should we clear map entries?
 } // else len==0: TODO: Should we clear map entries?
-z.DecReadMapEnd() {{/* z.DecSendContainerState(codecSelfer_containerMapEnd{{ .Sfx }}) */}}
+z.DecReadMapEnd()
 }
 }

+ 0 - 12
codec/gen-helper.go.tmpl

@@ -50,18 +50,6 @@ type genHelperDecDriver struct {
 	decDriver
 	decDriver
 }
 }
 
 
-{{/*
-// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
-func (x genHelperEncDriver) EncStructFieldKey(keyType valueType, s string) {
-	encStructFieldKey(s, x.encDriver, nil, keyType, false, false)
-}
-
-// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
-func (x genHelperDecDriver) DecStructFieldKey(keyType valueType, buf *[decScratchByteArrayLen]byte) []byte {
-	return decStructFieldKey(x.decDriver, keyType, buf)
-}
-*/ -}}
-
 // 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*
 type genHelperEncoder struct {
 type genHelperEncoder struct {
 	M must
 	M must

+ 3 - 3
codec/gen.generated.go

@@ -29,7 +29,7 @@ if z.DecBasicHandle().MapValueReset {
 if {{var "l"}} != 0 {
 if {{var "l"}} != 0 {
 	{{var "hl"}} := {{var "l"}} > 0 
 	{{var "hl"}} := {{var "l"}} > 0 
 	for {{var "j"}} := 0; ({{var "hl"}} && {{var "j"}} < {{var "l"}}) || !({{var "hl"}} || z.DecCheckBreak()); {{var "j"}}++ {
 	for {{var "j"}} := 0; ({{var "hl"}} && {{var "j"}} < {{var "l"}}) || !({{var "hl"}} || z.DecCheckBreak()); {{var "j"}}++ {
-	z.DecReadMapElemKey() {{/* z.DecSendContainerState(codecSelfer_containerMapKey{{ .Sfx }}) */}}
+	z.DecReadMapElemKey()
 	{{ $x := printf "%vmk%v" .TempVar .Rand }}{{ decLineVarK $x -}}
 	{{ $x := printf "%vmk%v" .TempVar .Rand }}{{ decLineVarK $x -}}
 	{{ if eq .KTyp "interface{}" }}{{/* // special case if a byte array. */ -}}
 	{{ if eq .KTyp "interface{}" }}{{/* // special case if a byte array. */ -}}
     if {{var "bv"}}, {{var "bok"}} := {{var "mk"}}.([]byte); {{var "bok"}} {
     if {{var "bv"}}, {{var "bok"}} := {{var "mk"}}.([]byte); {{var "bok"}} {
@@ -49,7 +49,7 @@ if {{var "l"}} != 0 {
         {{var "mv"}} = {{var "v"}}[{{var "mk"}}]
         {{var "mv"}} = {{var "v"}}[{{var "mk"}}]
         {{end -}}
         {{end -}}
 	} {{if not decElemKindImmutable}}else { {{var "mv"}} = {{decElemZero}} }{{end}}
 	} {{if not decElemKindImmutable}}else { {{var "mv"}} = {{decElemZero}} }{{end}}
-	z.DecReadMapElemValue() {{/* z.DecSendContainerState(codecSelfer_containerMapValue{{ .Sfx }}) */}}
+	z.DecReadMapElemValue()
 	{{var "mdn"}} = false
 	{{var "mdn"}} = false
 	{{ $x := printf "%vmv%v" .TempVar .Rand }}{{ $y := printf "%vmdn%v" .TempVar .Rand }}{{ decLineVar $x $y -}}
 	{{ $x := printf "%vmv%v" .TempVar .Rand }}{{ $y := printf "%vmdn%v" .TempVar .Rand }}{{ decLineVar $x $y -}}
 	if {{var "mdn"}} {
 	if {{var "mdn"}} {
@@ -59,7 +59,7 @@ if {{var "l"}} != 0 {
 	}
 	}
 }
 }
 } // else len==0: TODO: Should we clear map entries?
 } // else len==0: TODO: Should we clear map entries?
-z.DecReadMapEnd() {{/* z.DecSendContainerState(codecSelfer_containerMapEnd{{ .Sfx }}) */}}
+z.DecReadMapEnd()
 }
 }
 `
 `
 
 

+ 1 - 1
codec/sort-slice.go.tmpl

@@ -10,7 +10,7 @@ xxxIntfSlice
 xxxRv
 xxxRv
 xxxRvSlice
 xxxRvSlice
 
 
-I'm not going to create them for
+I'm now going to create them for
 - sortables
 - sortables
 - sortablesplus
 - sortablesplus