In v2 a default hasher (of strings) is missing
Closed this issue · 5 comments
Hi,
The xsync.StrHash64
function of v1
was very helpful and it is a shamed it is missing from v2
. Any reason why you decided not to make hashString
public?
I'll be happy to issue a pull request with such a change.
Cheers,
Shmul
That function was removed in favor of more flexible hash/maphash
-based hash functions. See an example of such function here:
Lines 21 to 32 in ace0f0f
If you have string
keys, it's trivial to implement a hash function with maphash.Hash
:
func(seed maphash.Seed, s string) uint64 {
var h maphash.Hash
h.SetSeed(seed)
h.WriteString(s)
return h.Sum64()
}
Thanks for the reply. It is well understood and seems right. All I'm asking for is to make it a public utility function as string keys are so common.
There are NewMapOf
and NewMapOfPresized
built-in constructors for typed maps with string
keys, so a separate function is not needed. Sorry for not mentioning this initially.
Perfect. Many thanks.
No problem at all. Feel free to reopen this issue or create a separate one if you find that the library API could be improved.