mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
lib/fastnum: use unsafe.Slice() instead of deprecated reflect.SliceHeader
This commit is contained in:
parent
a3cf3d7de1
commit
7a04f99c72
1 changed files with 4 additions and 13 deletions
|
@ -2,7 +2,6 @@ package fastnum
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"reflect"
|
|
||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -124,20 +123,12 @@ func isFloat64Data(a, data []float64) bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func int64ToByteSlice(a []int64) (b []byte) {
|
func int64ToByteSlice(a []int64) []byte {
|
||||||
sh := (*reflect.SliceHeader)(unsafe.Pointer(&b))
|
return unsafe.Slice((*byte)(unsafe.Pointer(unsafe.SliceData(a))), len(a)*8)
|
||||||
sh.Data = uintptr(unsafe.Pointer(&a[0]))
|
|
||||||
sh.Len = len(a) * int(unsafe.Sizeof(a[0]))
|
|
||||||
sh.Cap = sh.Len
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func float64ToByteSlice(a []float64) (b []byte) {
|
func float64ToByteSlice(a []float64) []byte {
|
||||||
sh := (*reflect.SliceHeader)(unsafe.Pointer(&b))
|
return unsafe.Slice((*byte)(unsafe.Pointer(unsafe.SliceData(a))), len(a)*8)
|
||||||
sh.Data = uintptr(unsafe.Pointer(&a[0]))
|
|
||||||
sh.Len = len(a) * int(unsafe.Sizeof(a[0]))
|
|
||||||
sh.Cap = sh.Len
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
Loading…
Reference in a new issue