rlp: using unsafe.Slice instead of SliceHeader

This commit is contained in:
cuiweixie 2024-02-24 21:50:46 +08:00
parent 93c541ad56
commit 7d8d4d27d3

View file

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