by nknight · 14y ago · 0 comments
Compares are reliably cheap (1-2 cycles), jumps are usually similar.
If the code is structured right, the simple two comparison mechanism is no worse than the division, and at best may be an order of magnitude faster.
A sufficiently smart JIT might end up deconstructing that division into the double-compare, but at that point, again, you're no better off.
So, Mr. Bray is setting an example that's probably slower, and definitely less intuitive, for no apparent gain.