1 Star 1 Fork 3

menuiis/gkit

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
util.go 1016 Bytes
一键复制 编辑 原始数据 按行查看 历史
SongZhibin97 提交于 2022-08-04 18:38 +08:00 . fix: xxhash3 race
// Package xxhash3 implements https://github.com/Cyan4973/xxHash/blob/dev/xxhash.h
package xxhash3
import (
"math/bits"
"unsafe"
"golang.org/x/sys/cpu"
)
var (
avx2 = cpu.X86.HasAVX2
sse2 = cpu.X86.HasSSE2
hashfunc = [2]func(unsafe.Pointer, int) uint64{xxh3HashSmall, xxh3HashLarge}
hashfunc128 = [2]func(unsafe.Pointer, int) [2]uint64{xxh3HashSmall128, xxh3HashLarge128}
)
type funcUnsafe int
const (
hashSmall funcUnsafe = iota
hashLarge
)
func mix(a, b uint64) uint64 {
hi, lo := bits.Mul64(a, b)
return hi ^ lo
}
func xxh3RRMXMX(h64 uint64, length uint64) uint64 {
h64 ^= bits.RotateLeft64(h64, 49) ^ bits.RotateLeft64(h64, 24)
h64 *= 0x9fb21c651e98df25
h64 ^= (h64 >> 35) + length
h64 *= 0x9fb21c651e98df25
h64 ^= (h64 >> 28)
return h64
}
func xxh64Avalanche(h64 uint64) uint64 {
h64 *= prime64_2
h64 ^= h64 >> 29
h64 *= prime64_3
h64 ^= h64 >> 32
return h64
}
func xxh3Avalanche(x uint64) uint64 {
x ^= x >> 37
x *= 0x165667919e3779f9
x ^= x >> 32
return x
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/menciis/gkit.git
git@gitee.com:menciis/gkit.git
menciis
gkit
gkit
d3f65ed26d21

搜索帮助