mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-15 08:23:34 +01:00
lib/protoparser/csvimport: unse unsafe.Slice instead of deprecated reflect.SliceHeader
This commit is contained in:
parent
9bc4c51ceb
commit
a9fb2e91a6
@ -3,7 +3,6 @@ package csvimport
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"reflect"
|
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@ -201,17 +200,8 @@ func equalColumnDescriptors(a, b []ColumnDescriptor) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func equalColumnDescriptor(x, y ColumnDescriptor) bool {
|
func equalColumnDescriptor(x, y ColumnDescriptor) bool {
|
||||||
var b1, b2 []byte
|
b1 := unsafe.Slice((*byte)(unsafe.Pointer(&x.ParseTimestamp)), int(unsafe.Sizeof(x.ParseTimestamp)))
|
||||||
|
b2 := unsafe.Slice((*byte)(unsafe.Pointer(&y.ParseTimestamp)), int(unsafe.Sizeof(y.ParseTimestamp)))
|
||||||
sh1 := (*reflect.SliceHeader)(unsafe.Pointer(&b1))
|
|
||||||
sh1.Data = uintptr(unsafe.Pointer(&x.ParseTimestamp))
|
|
||||||
sh1.Len = int(unsafe.Sizeof(x.ParseTimestamp))
|
|
||||||
sh1.Cap = int(unsafe.Sizeof(x.ParseTimestamp))
|
|
||||||
|
|
||||||
sh2 := (*reflect.SliceHeader)(unsafe.Pointer(&b2))
|
|
||||||
sh2.Data = uintptr(unsafe.Pointer(&y.ParseTimestamp))
|
|
||||||
sh2.Len = int(unsafe.Sizeof(y.ParseTimestamp))
|
|
||||||
sh2.Cap = int(unsafe.Sizeof(y.ParseTimestamp))
|
|
||||||
|
|
||||||
if !bytes.Equal(b1, b2) {
|
if !bytes.Equal(b1, b2) {
|
||||||
return false
|
return false
|
||||||
|
Loading…
Reference in New Issue
Block a user