rlp: using unsafe.Slice instead of SliceHeader (#29067)

Co-authored-by: Felix Lange <fjl@twurst.com>
This commit is contained in:
cui 2024-03-05 21:45:17 +08:00 committed by GitHub
parent a6d6e8ac41
commit a970295956
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -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)
}