3 ms·
Branchless Programming: Why “If” is slow and what we can do about it
- Alifatisk 3y agoTried implementing the first example in Ruby but a benchmark showed that a simple if-case was faster. I guess the RubyVM does a lot under the hood that hurts the performance like returning boolean true instead of the integer 1, which I have to solve by type conversion, thus degrading the performance. Monkeypatching is possible but adds more instructions to the vm anyways.