github.com/tobgu/qframe@v0.4.0/internal/hash/memhash.go (about) 1 package hash 2 3 import ( 4 "unsafe" 5 ) 6 7 //go:noescape 8 //go:linkname memhash runtime.memhash 9 func memhash(p unsafe.Pointer, seed, s uintptr) uintptr 10 11 type stringStruct struct { 12 str unsafe.Pointer 13 len int 14 } 15 16 func HashBytes(bb []byte, seed uint64) uint64 { 17 ss := (*stringStruct)(unsafe.Pointer(&bb)) 18 return uint64(memhash(ss.str, uintptr(seed), uintptr(ss.len))) 19 }