4 ms·
You put the condition that is most likely to be met first, not the least likely.
by say_it_as_it_is 3y ago
You put the condition that is most likely to be met first, not the least likely.
- nsonha 3y agoLol why? You are coding definitive rules not heuristics. The odd of the branch getting hit has no bearing here. When the edge cases get bloated, it’s time to make a validator function for your input and leave the main function with happy path only
- say_it_as_it_is 3y agoLoL! languages that support short-circuit evaluation will exit the conditional evaluation as soon as they reach a condition that is true, without evaluating subsequent conditions ... it also makes branch predictions more accurate