diff --git a/rlp/decode.go b/rlp/decode.go
index 5a06f35ec01..19074072fb4 100644
--- a/rlp/decode.go
+++ b/rlp/decode.go
@@ -371,7 +371,7 @@ func decodeByteArray(s *Stream, val reflect.Value) error {
if err != nil {
return err
}
- slice := byteArrayBytes(val, val.Len())
+ slice := val.Bytes()
switch kind {
case Byte:
if len(slice) == 0 {
diff --git a/rlp/encode.go b/rlp/encode.go
index de2b02f6294..ed992757390 100644
--- a/rlp/encode.go
+++ b/rlp/encode.go
@@ -240,7 +240,6 @@ func makeByteArrayWriter(typ reflect.Type) writer {
case 1:
return writeLengthOneByteArray
default:
- length := typ.Len()
return func(val reflect.Value, w *encBuffer) error {
if !val.CanAddr() {
// Getting the byte slice of val requires it to be addressable. Make it
@@ -249,7 +248,7 @@ func makeByteArrayWriter(typ reflect.Type) writer {
copy.Set(val)
val = copy
}
- slice := byteArrayBytes(val, length)
+ slice := val.Bytes()
w.encodeStringHeader(len(slice))
w.str = append(w.str, slice...)
return nil
diff --git a/rlp/safe.go b/rlp/safe.go
deleted file mode 100644
index 3c910337b6a..00000000000
--- a/rlp/safe.go
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright 2021 The go-ethereum Authors
-// This file is part of the go-ethereum library.
-//
-// The go-ethereum library is free software: you can redistribute it and/or modify
-// it under the terms of the GNU Lesser General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// The go-ethereum library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public License
-// along with the go-ethereum library. If not, see .
-
-//go:build nacl || js || !cgo
-// +build nacl js !cgo
-
-package rlp
-
-import "reflect"
-
-// byteArrayBytes returns a slice of the byte array v.
-func byteArrayBytes(v reflect.Value, length int) []byte {
- return v.Slice(0, length).Bytes()
-}
diff --git a/rlp/unsafe.go b/rlp/unsafe.go
deleted file mode 100644
index 10868caaf28..00000000000
--- a/rlp/unsafe.go
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright 2021 The go-ethereum Authors
-// This file is part of the go-ethereum library.
-//
-// The go-ethereum library is free software: you can redistribute it and/or modify
-// it under the terms of the GNU Lesser General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// The go-ethereum library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public License
-// along with the go-ethereum library. If not, see .
-
-//go:build !nacl && !js && cgo
-// +build !nacl,!js,cgo
-
-package rlp
-
-import (
- "reflect"
- "unsafe"
-)
-
-// byteArrayBytes returns a slice of the byte array v.
-func byteArrayBytes(v reflect.Value, length int) []byte {
- return unsafe.Slice((*byte)(unsafe.Pointer(v.UnsafeAddr())), length)
-}