mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
rlp: using unsafe.Slice instead of SliceHeader
This commit is contained in:
parent
93c541ad56
commit
7d8d4d27d3
1 changed files with 1 additions and 6 deletions
|
|
@ -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 a new issue