Skip to content

Commit 1693a48

Browse files
authored
rlp: remove workaround for Value.Bytes (ethereum#32433)
As of Go 1.19, it is permitted to call Bytes() on a reflect.Value representing an adressable byte array. So we can remove our workaround, undoing ethereum#22924. https://go.dev/doc/go1.19#reflectpkgreflect > The method [Value.Bytes](https://go.dev/pkg/reflect/#Value.Bytes) now accepts addressable arrays in addition to slices.
1 parent 1d29e3e commit 1693a48

File tree

4 files changed

+2
-60
lines changed

4 files changed

+2
-60
lines changed

rlp/decode.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ func decodeByteArray(s *Stream, val reflect.Value) error {
371371
if err != nil {
372372
return err
373373
}
374-
slice := byteArrayBytes(val, val.Len())
374+
slice := val.Bytes()
375375
switch kind {
376376
case Byte:
377377
if len(slice) == 0 {

rlp/encode.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,6 @@ func makeByteArrayWriter(typ reflect.Type) writer {
240240
case 1:
241241
return writeLengthOneByteArray
242242
default:
243-
length := typ.Len()
244243
return func(val reflect.Value, w *encBuffer) error {
245244
if !val.CanAddr() {
246245
// Getting the byte slice of val requires it to be addressable. Make it
@@ -249,7 +248,7 @@ func makeByteArrayWriter(typ reflect.Type) writer {
249248
copy.Set(val)
250249
val = copy
251250
}
252-
slice := byteArrayBytes(val, length)
251+
slice := val.Bytes()
253252
w.encodeStringHeader(len(slice))
254253
w.str = append(w.str, slice...)
255254
return nil

rlp/safe.go

Lines changed: 0 additions & 27 deletions
This file was deleted.

rlp/unsafe.go

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)