4 ms·
there are lots of "experts" who will tell you that the branch for either outcome of an if can only be executed after the if condition is evaluated, and that the
by naikrovek 4y ago
there are lots of "experts" who will tell you that the branch for either outcome of an if can only be executed after the if condition is evaluated, and that therefore "ifs are slow; don't use if".
I had a colleague once that would turn all his "if" statements into "switch" clauses because "no branches means it is so much faster" and people listened to him closely.
- rep_lodsb 4y agoHow could anyone believe that switch would work without evaluating its argument or branching?
- naikrovek 4y agoif you believe the person saying it is an "expert", that's how. "i-am-an-expert" syndrome often seen in 24-yo "senior" developers with sizeable egos.
- 8n4vidtmkvmk 4y agoi avoid some ifs for perf.. but only when i can write something equivalent with like 1 line and certainly not a switch