stclib / STC

A modern, user friendly, generic, type-safe and fast C99 container library: String, Vector, Sorted and Unordered Map and Set, Deque, Forward List, Smart Pointers, Bitset and Random numbers.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

String hash function looses 2 "bits" per 8 bytes

funny-falcon opened this issue · comments

https://github.com/tylov/STC/blob/fddae5ef07fc0e9a018e56a9843e059a737e4db7/include/stc/ccommon.h#L144

rot(x,z)^x == rot(~x, z)^(~x)

And rotating even bytes introduces more collisions

m1 = 0x5555555555555555ull;
m2 = 0xaaaaaaaaaaaaaaaaull;
rot(x,26)^x == rot(x^m1, 26) ^ (x^m1) == rot(x^m2, 26) ^ (x^m2);

Hash function changed in unreleased v4.3, closed as not applicable.