rlp: using unsafe.Slice instead of SliceHeader (#29067)
Co-authored-by: Felix Lange <fjl@twurst.com>
This commit is contained in:
parent
a6d6e8ac41
commit
a970295956
@ -26,10 +26,5 @@ import (
|
|||||||
|
|
||||||
// byteArrayBytes returns a slice of the byte array v.
|
// byteArrayBytes returns a slice of the byte array v.
|
||||||
func byteArrayBytes(v reflect.Value, length int) []byte {
|
func byteArrayBytes(v reflect.Value, length int) []byte {
|
||||||
var s []byte
|
return unsafe.Slice((*byte)(unsafe.Pointer(v.UnsafeAddr())), length)
|
||||||
hdr := (*reflect.SliceHeader)(unsafe.Pointer(&s))
|
|
||||||
hdr.Data = v.UnsafeAddr()
|
|
||||||
hdr.Cap = length
|
|
||||||
hdr.Len = length
|
|
||||||
return s
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user