Skip to content

Commit a03e26d

Browse files
committed
codec: remove comment blocks at bottom of files
We kept commented out code at bottom of files for easy access. As we prepare to release a new version, we can now clean up the codebase and remove the clutter.
1 parent a2e50fc commit a03e26d

21 files changed

+0
-2380
lines changed

codec/0_init_test.go

Lines changed: 0 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -223,76 +223,3 @@ func approxDataSize(rv reflect.Value) (sum int) {
223223
}
224224
return
225225
}
226-
227-
// // --- functions below are used by both benchmarks and tests
228-
229-
// // log message only when testVerbose = true (ie go test ... -- -tv).
230-
// //
231-
// // These are for intormational messages that do not necessarily
232-
// // help with diagnosing a failure, or which are too large.
233-
// func logTv(x interface{}, format string, args ...interface{}) {
234-
// if !testVerbose {
235-
// return
236-
// }
237-
// if t, ok := x.(testing.TB); ok { // only available from go 1.9
238-
// t.Helper()
239-
// }
240-
// logT(x, format, args...)
241-
// }
242-
243-
// // logT logs messages when running as go test -v
244-
// //
245-
// // Use it for diagnostics messages that help diagnost failure,
246-
// // and when the output is not too long ie shorter than like 100 characters.
247-
// //
248-
// // In general, any logT followed by failT should call this.
249-
// func logT(x interface{}, format string, args ...interface{}) {
250-
// if x == nil {
251-
// if len(format) == 0 || format[len(format)-1] != '\n' {
252-
// format = format + "\n"
253-
// }
254-
// fmt.Printf(format, args...)
255-
// return
256-
// }
257-
// if t, ok := x.(testing.TB); ok { // only available from go 1.9
258-
// t.Helper()
259-
// t.Logf(format, args...)
260-
// }
261-
// }
262-
263-
// func failTv(x testing.TB, args ...interface{}) {
264-
// x.Helper()
265-
// if testVerbose {
266-
// failTMsg(x, args...)
267-
// }
268-
// x.FailNow()
269-
// }
270-
271-
// func failT(x testing.TB, args ...interface{}) {
272-
// x.Helper()
273-
// failTMsg(x, args...)
274-
// x.FailNow()
275-
// }
276-
277-
// func failTMsg(x testing.TB, args ...interface{}) {
278-
// x.Helper()
279-
// if len(args) > 0 {
280-
// if format, ok := args[0].(string); ok {
281-
// logT(x, format, args[1:]...)
282-
// } else if len(args) == 1 {
283-
// logT(x, "%v", args[0])
284-
// } else {
285-
// logT(x, "%v", args)
286-
// }
287-
// }
288-
// }
289-
290-
// --- functions below are used only by benchmarks alone
291-
292-
// func benchFnCodecEncode(ts interface{}, bsIn []byte, h Handle) (bs []byte, err error) {
293-
// return testCodecEncode(ts, bsIn, fnBenchmarkByteBuf, h)
294-
// }
295-
296-
// func benchFnCodecDecode(bs []byte, ts interface{}, h Handle) (err error) {
297-
// return testCodecDecode(bs, ts, h)
298-
// }

codec/base.notfastpath.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,3 @@ type fastpathRtRtid struct {
3232
type fastpathARtRtid [0]fastpathRtRtid
3333

3434
var fastpathAvRtRtid fastpathARtRtid
35-
36-
//var fastpathAV fastpathA
37-
// var fastpathTV fastpathT

codec/codec_run_test.go

Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -4178,74 +4178,3 @@ func testEqualH(v1, v2 interface{}, h Handle) (err error) {
41784178
}
41794179
return
41804180
}
4181-
4182-
// func testEqualH(v1, v2 interface{}, h Handle) (err error) {
4183-
// // ...
4184-
// //
4185-
// // var o gocmp.Option
4186-
// // var p []gocmp.Option
4187-
// // if zeroAsNil {
4188-
// // }
4189-
// // if mapKeyAsStr {
4190-
// // }
4191-
// // if bh.NilCollectionToZeroLength {
4192-
// //
4193-
// // ...
4194-
// //
4195-
// // o = gocmpopts.AcyclicTransformer("T1", f)
4196-
// // p = append(p, o)
4197-
// // if !gocmp.Equal(v1, v2, p...) {
4198-
// // if testv.UseDiff {
4199-
// // err = errors.New(gocmp.Diff(v1, v2, p...))
4200-
// // } else {
4201-
// // err = errDeepEqualNotMatch
4202-
// // }
4203-
// // }
4204-
// // return
4205-
// //
4206-
// // ...
4207-
// //
4208-
// // o = cmp.Transformer("T1", func(in interface{}) (out interface{}) {
4209-
// // out.Real, out.Imag = real(in), imag(in)
4210-
// // return out
4211-
// // })
4212-
// }
4213-
4214-
// type testUnixNanoTimeExt struct {
4215-
// // keep timestamp here, so that do not incur interface-conversion costs
4216-
// // ts int64
4217-
// }
4218-
4219-
// func (x *testUnixNanoTimeExt) WriteExt(v interface{}) []byte {
4220-
// v2 := v.(*time.Time)
4221-
// bs := make([]byte, 8)
4222-
// bigenstd.PutUint64(bs, uint64(v2.UnixNano()))
4223-
// return bs
4224-
// }
4225-
// func (x *testUnixNanoTimeExt) ReadExt(v interface{}, bs []byte) {
4226-
// v2 := v.(*time.Time)
4227-
// ui := bigenstd.Uint64(bs)
4228-
// *v2 = time.Unix(0, int64(ui)).UTC()
4229-
// }
4230-
4231-
// type testUnixNanoTimeInterfaceExt struct{}
4232-
4233-
// func (x testUnixNanoTimeInterfaceExt) ConvertExt(v interface{}) interface{} {
4234-
// v2 := v.(*time.Time) // structs are encoded by passing the ptr
4235-
// return v2.UTC().UnixNano()
4236-
// }
4237-
4238-
// func (x testUnixNanoTimeInterfaceExt) UpdateExt(dest interface{}, v interface{}) {
4239-
// tt := dest.(*time.Time)
4240-
// *tt = time.Unix(0, v.(int64)).UTC()
4241-
// // switch v2 := v.(type) {
4242-
// // case int64:
4243-
// // *tt = time.Unix(0, v2).UTC()
4244-
// // case uint64:
4245-
// // *tt = time.Unix(0, int64(v2)).UTC()
4246-
// // //case float64:
4247-
// // //case string:
4248-
// // default:
4249-
// // panic(fmt.Errorf("unsupported format for time conversion: expecting int64/uint64; got %T", v))
4250-
// // }
4251-
// }

codec/decode.base.go

Lines changed: 0 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -942,85 +942,3 @@ func bytesOKdbi(v []byte, _ dBytesIntoState) []byte {
942942
func bytesOKs(bs []byte, _ dBytesAttachState) []byte {
943943
return bs
944944
}
945-
946-
// ----
947-
948-
// func (d *decoderBase) isAttachedReaderBytes(usingBuf bool) bool {
949-
// return usingBuf || !(d.bytes && d.zeroCopy)
950-
// }
951-
952-
// func (d *decoderBase) stringZC(v []byte, state dBytesAttachState) (s string) {
953-
// // This method is called a lot. Inlining helps with performance.
954-
// //
955-
// // MARKER: TUNED BELOW TO force inlining
956-
// // - inlined d.string(...)
957-
// // - remove if len(v) == 0 { check
958-
// // - used double indexing to eliminate inline cost of the addition (v[0]:v[0]+1)
959-
960-
// // if len(v) == 0 {
961-
// // } else if len(v) == 1 {
962-
// if len(v) == 1 {
963-
// s = str4byte(v[0]) // str256[v[0]:][:1] // str256[v[0] : v[0]+1]
964-
// // s = unsafe.String((*byte)(unsafe.Add(unsafe.Pointer(unsafe.StringData(str256)), v[0])), 1)
965-
// } else if state == dBytesAttachViewZerocopy { // !scratchBuf && d.bytes && d.zeroCopy
966-
// s = stringView(v)
967-
// } else if d.is == nil || d.c != containerMapKey || len(v) > internMaxStrLen {
968-
// s = string(v)
969-
// } else {
970-
// s = d.is.string(v)
971-
// }
972-
// return
973-
// }
974-
975-
// func (d *decoderBase) string(v []byte) (s string) {
976-
// if d.is == nil || d.c != containerMapKey || len(v) < 2 || len(v) > internMaxStrLen {
977-
// return string(v)
978-
// }
979-
// return d.is.string(v)
980-
// }
981-
982-
// func (x decNegintPosintFloatNumberHelper) roundFloat(v float64, prec int) float64 {
983-
// ratio := math.Pow(10, float64(prec))
984-
// return math.Round(v*ratio) / ratio
985-
// }
986-
987-
// func (d *decoderBase) interfaceExtConvertAndDecodeGetRV(v interface{}, ext InterfaceExt) reflect.Value {
988-
// // var v interface{} = ext.ConvertExt(rv)
989-
// // d.d.decode(&v)
990-
// // ext.UpdateExt(rv, v)
991-
992-
// // assume v is a pointer:
993-
// // - if struct|array, pass as is to ConvertExt
994-
// // - else make it non-addressable and pass to ConvertExt
995-
// // - make return value from ConvertExt addressable
996-
// // - decode into it
997-
// // - return the interface for passing into UpdateExt.
998-
// // - interface should be a pointer if struct|array, else a value
999-
1000-
// var s interface{}
1001-
// rv := reflect.ValueOf(v)
1002-
// rv2 := rv.Elem()
1003-
// rvk := rv2.Kind()
1004-
// if rvk == reflect.Struct || rvk == reflect.Array {
1005-
// s = ext.ConvertExt(v)
1006-
// } else {
1007-
// s = ext.ConvertExt(rv2i(rv2))
1008-
// }
1009-
// rv = reflect.ValueOf(s)
1010-
1011-
// // We cannot use isDecodeable here, as the value converted may be nil,
1012-
// // or it may not be nil but is not addressable and thus we cannot extend it, etc.
1013-
// // Instead, we just ensure that the value is addressable.
1014-
1015-
// if !rv.CanAddr() {
1016-
// rvk = rv.Kind()
1017-
// rv2 = d.oneShotAddrRV(rv.Type(), rvk)
1018-
// if rvk == reflect.Interface {
1019-
// rvSetIntf(rv2, rv)
1020-
// } else {
1021-
// rvSetDirect(rv2, rv)
1022-
// }
1023-
// rv = rv2
1024-
// }
1025-
// return rv
1026-
// }

codec/decode.go

Lines changed: 0 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -1959,119 +1959,3 @@ func (dh helperDecDriver[T]) decFnLoad(rt reflect.Type, rtid uintptr, tinfos *Ty
19591959
}
19601960
return
19611961
}
1962-
1963-
// // --------------------------------------------------
1964-
1965-
// // decSliceHelper assists when decoding into a slice, from a map or an array in the stream.
1966-
// // A slice can be set from a map or array in stream. This supports the MapBySlice interface.
1967-
// //
1968-
// // Note: if IsNil, do not call ElemContainerState.
1969-
// type decSliceHelper[T decDriver] struct {
1970-
// d *decoder[T]
1971-
// ct valueType
1972-
// Array bool
1973-
// IsNil bool
1974-
// }
1975-
1976-
// func (d *decoder[T]) decSliceHelperStart() (x decSliceHelper[T], clen int) {
1977-
// x.ct = d.d.ContainerType()
1978-
// x.d = d
1979-
// switch x.ct {
1980-
// case valueTypeNil:
1981-
// x.IsNil = true
1982-
// case valueTypeArray:
1983-
// x.Array = true
1984-
// clen = d.arrayStart(d.d.ReadArrayStart())
1985-
// case valueTypeMap:
1986-
// clen = d.mapStart(d.d.ReadMapStart())
1987-
// clen += clen
1988-
// default:
1989-
// halt.errorStr2("to decode into a slice, expect map/array - got ", x.ct.String())
1990-
// }
1991-
// return
1992-
// }
1993-
1994-
// func (x decSliceHelper[T]) End() {
1995-
// if x.IsNil {
1996-
// } else if x.Array {
1997-
// x.d.arrayEnd()
1998-
// } else {
1999-
// x.d.mapEnd()
2000-
// }
2001-
// }
2002-
2003-
// func (x decSliceHelper[T]) ElemContainerState(index int) {
2004-
// // Note: if isnil, clen=0, so we never call into ElemContainerState
2005-
// if x.Array {
2006-
// x.d.arrayElem(index == 0)
2007-
// } else if index&1 == 0 { // index%2 == 0 {
2008-
// x.d.mapElemKey(index == 0)
2009-
// } else {
2010-
// x.d.mapElemValue()
2011-
// }
2012-
// }
2013-
2014-
// // func (x decSliceHelper[T]) arrayCannotExpand(hasLen bool, lenv, j, containerLenS int) {
2015-
// // x.d.arrayCannotExpand(lenv, j+1)
2016-
// // // drain completely and return
2017-
// // x.ElemContainerState(j)
2018-
// // x.d.swallow()
2019-
// // j++
2020-
// // for ; x.d.containerNext(j, containerLenS, hasLen); j++ {
2021-
// // x.ElemContainerState(j)
2022-
// // x.d.swallow()
2023-
// // }
2024-
// // x.End()
2025-
// // }
2026-
2027-
// func (x decSliceHelper[T]) arrayCannotExpand(hasLen bool, lenv, j, containerLenS int) {
2028-
// x.d.arrayCannotExpand(lenv, j+1)
2029-
// x.d.drainSeq(x.ct == valueTypeArray, hasLen, containerLenS, j)
2030-
// }
2031-
2032-
// func (d *decoder[T]) drainSeq(isArray, hasLen bool, containerLenS, j int) {
2033-
// // drain completely and return
2034-
// LOOP:
2035-
// if isArray {
2036-
// d.arrayElem(j == 0)
2037-
// } else if j&1 == 0 {
2038-
// d.mapElemKey(j == 0)
2039-
// } else {
2040-
// d.mapElemValue()
2041-
// }
2042-
// d.swallow()
2043-
// j++
2044-
// if d.containerNext(j, containerLenS, hasLen) {
2045-
// goto LOOP
2046-
// }
2047-
// if isArray {
2048-
// d.arrayEnd()
2049-
// } else {
2050-
// d.mapEnd()
2051-
// }
2052-
// }
2053-
2054-
// func (d *decoder[T]) swallowErr() (err error) {
2055-
// if !debugging {
2056-
// defer func() {
2057-
// if x := recover(); x != nil {
2058-
// panicValToErr(d, x, &err)
2059-
// }
2060-
// }()
2061-
// }
2062-
// d.swallow()
2063-
// return
2064-
// }
2065-
2066-
// func (d *decoder[T]) zerocopy() bool {
2067-
// return d.bytes && d.h.ZeroCopy
2068-
// }
2069-
2070-
// // decodeFloat32 will delegate to an appropriate DecodeFloat32 implementation (if exists),
2071-
// // else if will call DecodeFloat64 and ensure the value doesn't overflow.
2072-
// //
2073-
// // Note that we return float64 to reduce unnecessary conversions
2074-
// func (d *decoder[T]) decodeFloat32() float32 {
2075-
// d.d.DecodeFloat32() // custom implementation for 32-bit
2076-
// return float32(chkOvf.Float32V(d.d.DecodeFloat64()))
2077-
// }

0 commit comments

Comments
 (0)