N-R-K / ChibiHash

Small, Fast, Portable 64-bit hash function
https://nrk.neocities.org/articles/chibihash
88 stars 1 forks source link

Go port of this excellent project #1

Open rainrambler opened 6 days ago

rainrambler commented 6 days ago

This project has been incredibly inspiring and useful in my own projects.

I recently created a Go port of ChibiHash, and I would be thrilled if you could take a look at it. ==> https://github.com/rainrambler/ChibiHashGo

Please consider adding a link to my project in your readme file, as I believe it could be beneficial to others in the community who are interested in using Go.

Thank you once again for your amazing work.

N-R-K commented 6 days ago

Hello,

Thanks for the port. I have some concerns however. I do not read/understand Go code well, but from what I can tell, you're using a kpos index variable to keep track of the string position.

But in some places it's reading from k[0], shouldn't that read from k[kpos] instead?

I have run the C version on a couple inputs and collected the results. Can you verify the Go port matches these results?

// chibihash64(string, len, seed)
chibihash64("", 0, 0) => 0x9EA80F3B18E26CFB
chibihash64("", 0, 55555) => 0x2EED9399FC4AC7E5
chibihash64("hi", 2, 0) => 0xAF98F3924F5C80D6
chibihash64("123", 3, 0) => 0x893A5CCA05B0A883
chibihash64("abcdefgh", 8, 0) => 0x8F922660063E3E75
chibihash64("Hello, world!", 13, 0) => 0x5AF920D8C0EBFE9F
chibihash64("qwertyuiopasdfghjklzxcvbnm123456", 32, 0) => 0x2EF296DB634F6551
chibihash64("qwertyuiopasdfghjklzxcvbnm123456789", 35, 0) => 0x0F56CF3735FFA943

I also see that there is some length checks inside the latter two loops, but they should be unnecessary because those loops will run for 3 iterations max.