From a970295956d602c348dccce034712c14aedce5e0 Mon Sep 17 00:00:00 2001 From: cui <523516579@qq.com> Date: Tue, 5 Mar 2024 21:45:17 +0800 Subject: [PATCH] rlp: using unsafe.Slice instead of SliceHeader (#29067) Co-authored-by: Felix Lange --- rlp/unsafe.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/rlp/unsafe.go b/rlp/unsafe.go index 2152ba35fc..10868caaf2 100644 --- a/rlp/unsafe.go +++ b/rlp/unsafe.go @@ -26,10 +26,5 @@ import ( // byteArrayBytes returns a slice of the byte array v. func byteArrayBytes(v reflect.Value, length int) []byte { - var s []byte - hdr := (*reflect.SliceHeader)(unsafe.Pointer(&s)) - hdr.Data = v.UnsafeAddr() - hdr.Cap = length - hdr.Len = length - return s + return unsafe.Slice((*byte)(unsafe.Pointer(v.UnsafeAddr())), length) }