3 ms·
Compilers would turn that into a jump table: https://godbolt.org/z/14h5djYe8 https://godbolt.org/z/14h5djYe8 Although this looks branchless if you don't care
by secondcoming 1y ago
Compilers would turn that into a jump table:
https://godbolt.org/z/14h5djYe8 https://godbolt.org/z/14h5djYe8
Although this looks branchless if you don't care about divide-by-zero. The ALU might not be too happy:
https://godbolt.org/z/9nqG3xMPY https://godbolt.org/z/9nqG3xMPY