Make sure that the modulo is known at compile-time so the compiler can optimize it using and (for power of 2) and shifts.
Modulo is much more expensive than a mispredicted branch.
Make sure that the modulo is known at compile-time so the compiler can optimize it using and (for power of 2) and shifts.
Modulo is much more expensive than a mispredicted branch.