Skip to content

Commit bf79b21

Browse files
committed
codec: nits
1 parent 3a566c2 commit bf79b21

File tree

3 files changed

+23
-22
lines changed

3 files changed

+23
-22
lines changed

codec/cbor_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ func TestCborGoldens(t *testing.T) {
164164
bh.MapType = testMapStrIntfTyp
165165
bh.RawToString = false
166166
bh.SignedInteger = false
167-
// ch.SkipUnexpectedTags = false // MARKER 2025 - shouldn't be needed
167+
ch.SkipUnexpectedTags = false
168168

169169
// decode test-cbor-goldens.json into a list of []*testCborGolden
170170
// for each one,

codec/codec_run_test.go

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4032,7 +4032,8 @@ func testUpdateExts(nhs ...testNameBasicHandle) {
40324032
// add extensions for time.Time, excl json and binc (which have builtin support)
40334033
switch nh.n {
40344034
case "cbor":
4035-
sx(timeTyp, 1, tUnixTimeIntfExt) // MARKER 2025 (need to test ext here - not depend on builtin support)
4035+
// explicitly test ext here - not depend on builtin support)
4036+
sx(timeTyp, 1, tUnixTimeIntfExt)
40364037
case "msgpack":
40374038
sx(timeTyp, 1, tTimeBytesExt)
40384039
case "simple":
@@ -4146,19 +4147,19 @@ func testEqualH(v1, v2 interface{}, h Handle) (err error) {
41464147
rcopy(src.Field(i), target.Field(i))
41474148
}
41484149
}
4149-
case reflect.String:
4150-
// MARKER 2025 - need to all use same functions to compare
4151-
// s := src.String()
4152-
// if isJson && bh.StringToRaw {
4153-
// s = base64.StdEncoding.EncodeToString(bytesView(s))
4154-
// // dbuf := make([]byte, base64.StdEncoding.DecodedLen(len(s)))
4155-
// // n, err := base64.StdEncoding.Decode(dbuf, bytesView(s))
4156-
// // if err == nil {
4157-
// // s = stringView(dbuf[:n])
4158-
// // }
4159-
// }
4160-
// target.SetString(s)
4161-
target.Set(src)
4150+
// case reflect.String:
4151+
// // MARKER 2025 - need to all use same functions to compare
4152+
// // s := src.String()
4153+
// // if isJson && bh.StringToRaw {
4154+
// // s = base64.StdEncoding.EncodeToString(bytesView(s))
4155+
// // // dbuf := make([]byte, base64.StdEncoding.DecodedLen(len(s)))
4156+
// // // n, err := base64.StdEncoding.Decode(dbuf, bytesView(s))
4157+
// // // if err == nil {
4158+
// // // s = stringView(dbuf[:n])
4159+
// // // }
4160+
// // }
4161+
// // target.SetString(s)
4162+
// target.Set(src)
41624163
default: // Basic types: int, string, bool, etc.
41634164
target.Set(src)
41644165
// if src.Type().AssignableTo(target.Type()) {

codec/encode.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1678,15 +1678,15 @@ func (dh helperEncDriver[T]) encFnLoad(rt reflect.Type, rtid uintptr, tinfos *Ty
16781678
// func (e *encoder[T]) encodeIR(iv interface{}, rv reflect.Value) {
16791679
// // MARKER: a switch with only concrete types can be optimized.
16801680
// // consequently, we deal with nil and interfaces outside the switch.
1681-
1681+
//
16821682
// _ = e.e // early asserts e, e.e are not nil once
16831683
// if iv == nil {
16841684
// e.e.EncodeNil()
16851685
// return
16861686
// }
1687-
1687+
//
16881688
// k := rv.Kind()
1689-
1689+
//
16901690
// if isnilBitset.isset(byte(k)) && rvIsNil(rv) {
16911691
// if e.h.NilCollectionToZeroLength {
16921692
// switch k {
@@ -1701,21 +1701,21 @@ func (dh helperEncDriver[T]) encFnLoad(rt reflect.Type, rtid uintptr, tinfos *Ty
17011701
// e.e.EncodeNil()
17021702
// return
17031703
// }
1704-
1704+
//
17051705
// // rv, isnil := isNil(iv, true) // fast isNil check (e.g. for nil intf or nil pointers)
17061706
// // if isnil {
1707-
// // e.e.EncodeNil() // problem here MARKER 2025
1707+
// // e.e.EncodeNil() // problem here
17081708
// // return
17091709
// // }
1710-
1710+
//
17111711
// switch v := iv.(type) {
17121712
// // case nil:
17131713
// // case Selfer:
17141714
// case Raw:
17151715
// e.rawBytes(v)
17161716
// case reflect.Value:
17171717
// e.encodeValue(v, nil)
1718-
1718+
//
17191719
// case string:
17201720
// e.e.EncodeString(v)
17211721
// case bool:

0 commit comments

Comments
 (0)