app/vmselect/netstorage: usae unsafe.SliceData instead of deprecated reflect.SliceHeader

This commit is contained in:
Aliaksandr Valialkin 2024-02-29 17:36:28 +02:00
parent 01d8bee14c
commit 319d21eddf
No known key found for this signature in database
GPG key ID: 52C003EE2BCDB9EB

View file

@ -9,7 +9,6 @@ import (
"net"
"net/http"
"os"
"reflect"
"sort"
"strings"
"sync"
@ -1396,9 +1395,11 @@ func canAppendToBlockAddrPool(pool, a []tmpBlockAddr) bool {
// a doesn't belong to pool
return false
}
shPool := (*reflect.SliceHeader)(unsafe.Pointer(&pool))
shA := (*reflect.SliceHeader)(unsafe.Pointer(&a))
return shPool.Data+uintptr(shPool.Len)*unsafe.Sizeof(tmpBlockAddr{}) == shA.Data+uintptr(shA.Len)*unsafe.Sizeof(tmpBlockAddr{})
return getBlockAddrsEnd(pool) == getBlockAddrsEnd(a)
}
func getBlockAddrsEnd(a []tmpBlockAddr) uintptr {
return uintptr(unsafe.Pointer(unsafe.SliceData(a))) + uintptr(len(a))*unsafe.Sizeof(tmpBlockAddr{})
}
func (tbfwLocal *tmpBlocksFileWrapperShard) newBlockAddrs() int {