4 ms·
It was 10% faster to switch from modulo to & on a recent real world problem for me.
by spullara 14y ago
It was 10% faster to switch from modulo to & on a recent real world problem for me.
- brlewis 14y agoI believe you. There are two reasons I think paul's right in the context of hash tables. 1. If you're using a non-trivial hash function, one more modulo calculation at the end to get the actual memory address is not a big difference. 2. If you're using a trivial hash function, I bet for a lot of data sets you'll get fewer collisions with a hash table whose size is a prime number, canceling out any benefit from calculating the address slightly faster.