// generate a unique hash for a string of the specified bit length
// NOTE: make sure this is as fast as possible
//
// see: http://programmers.stackexchange.com/a/145633
generate a unique hash for a string of the specified bit length
NOTE: make sure this is as fast as possible

programmers.stackexchange.com/a/145633
// generate a unique hash for a string of the specified bit length // NOTE : make sure this is as fast as possible // // see : http : // programmers . stackexchange . com / a / 145633
func hash(s string, b uint32) uint32 {
	h := fnv.New32a()
	_, err := h.Write([]byte(s))
	if err != nil {
		panic(err)
	}
	val := h.Sum32()
	if b == 0 {
		return val
	}
	return val & ((1 << b) - 1)
}
func hash ( s string , b uint32 ) uint32 { h := fnv . New32a ( ) _ , err := h . Write ( [ ] byte ( s ) ) if err != nil { panic ( err ) } val := h . Sum32 ( ) if b == 0 { return val } return val & ( ( 1 << b ) - 1 ) }
generate a unique hash for a string of the specified bit length
NOTE: make sure this is as fast as possible
generate a unique hash for a string of the specified bit length NOTE : make sure this is as fast as possible