4144170cfc
and let the compiler do the optimization and unroll the binary search itself. I wrote a micro benchmark: 1. switch_fallthrough: 9597502784 ns 2. switch_return: 8921069697 ns 3. binary_search: 18403018625 ns The results are pretty consistent over multiple runs. 1st is switch case with one return at the end and lots of fallthrough. 2nd is a return of each case, 3rd is the original code. |
||
---|---|---|
.. | ||
bin |