Skip to content

Instantly share code, notes, and snippets.

@tufanbarisyildirim
Last active April 29, 2020 13:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tufanbarisyildirim/cbd576a89274992fecd51ed15bc5a601 to your computer and use it in GitHub Desktop.
Save tufanbarisyildirim/cbd576a89274992fecd51ed15bc5a601 to your computer and use it in GitHub Desktop.
zero allication fnv hashing of #golang
// https://github.com/golang/go/blob/master/src/hash/fnv/fnv.go#L100 the code we previously used
// has some allocations
// we need minimum footprint per deciding
func findIndex(s string, poolSize uint32) uint32 {
var h32a uint32 = 2166136261
for _, c := range []byte(s) {
h32a *= 16777619
h32a ^= uint32(c)
}
return h32a % poolSize
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment