Last active
April 29, 2020 13:37
-
-
Save tufanbarisyildirim/cbd576a89274992fecd51ed15bc5a601 to your computer and use it in GitHub Desktop.
zero allication fnv hashing of #golang
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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