lolly/internal/hash/hash.go
xfy 31faf77fcc style: add doc comments for exported hash and utils functions
Fix revive lint warnings for FNV64a, FNV64aBytes, BytesContainsFold.
2026-06-04 11:17:08 +08:00

22 lines
465 B
Go

package hash
// FNV64a computes FNV-1a hash without allocation.
func FNV64a(key string) uint64 {
var h uint64 = 14695981039346656037
for i := 0; i < len(key); i++ {
h ^= uint64(key[i])
h *= 1099511628211
}
return h
}
// FNV64aBytes computes FNV-1a hash from byte slice without allocation.
func FNV64aBytes(key []byte) uint64 {
var h uint64 = 14695981039346656037
for i := 0; i < len(key); i++ {
h ^= uint64(key[i])
h *= 1099511628211
}
return h
}