How hard is it to check for whitespace?
17 points by serce
17 points by serce
Perfect hashing is ready cute! The implementation is very small and simple even though it's very fast: it's just the proof that it does actually work which is complicated. :D
The magic 1682554634 number does look magical, and it's unclear to me how it was chosen (please do share if you know the answer).
I think it’s usually just brute forced, right?
I think it’s usually just brute forced, right?
Quite possibly, but I'm not sure how and why they arrived at exactly this number since it's one of many options.
Some multiplications are faster than others, as compilers will try to use additions, shifts, and the special address-offset computation instructions to avoid using the general-purpose mulitplication circuits. But I didn't notice any regularities in 1682554634 that would enable fast multiplication.