Skip to content

Commit dde1d15

Browse files
MichaelMurervagg
authored andcommitted
deprecate DumpObject() in favor of better named Encode()
1 parent 2e94acd commit dde1d15

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

node.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,8 +396,13 @@ func (n *Node) MarshalJSON() ([]byte, error) {
396396
}
397397

398398
// DumpObject marshals any object into its CBOR serialized byte representation
399-
// TODO: rename
399+
// Deprecated: use Encode instead.
400400
func DumpObject(obj interface{}) (out []byte, err error) {
401+
return Encode(obj)
402+
}
403+
404+
// Encode marshals any object into its CBOR serialized byte representation
405+
func Encode(obj interface{}) (out []byte, err error) {
401406
return marshaller.Marshal(obj)
402407
}
403408

node_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ func TestBigIntRoundtrip(t *testing.T) {
593593
World: *big.NewInt(99),
594594
}
595595

596-
bytes, err := DumpObject(&one)
596+
bytes, err := Encode(&one)
597597
if err != nil {
598598
t.Fatal(err)
599599
}
@@ -616,7 +616,7 @@ func TestBigIntRoundtrip(t *testing.T) {
616616
"world": {Hello: big.NewInt(9), World: *big.NewInt(901), Hi: 3},
617617
}
618618

619-
bytes, err = DumpObject(list)
619+
bytes, err = Encode(list)
620620
if err != nil {
621621
t.Fatal(err)
622622
}

wrap_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,10 @@ func BenchmarkDecodeBlockParallel(b *testing.B) {
111111
}
112112
}
113113

114-
func BenchmarkDumpObject(b *testing.B) {
114+
func BenchmarkEncode(b *testing.B) {
115115
obj := testStruct()
116116
for i := 0; i < b.N; i++ {
117-
bytes, err := DumpObject(obj)
117+
bytes, err := Encode(obj)
118118
if err != nil {
119119
b.Fatal(err, bytes)
120120
}

0 commit comments

Comments
 (0)