+ 1
What is better for checking equality, a switch case or an if else block
2 Respostas
+ 4
@Ace That information is incorrect, I'm assuming you also got it from this stack overflow answer, since you basically said the same exact thing. https://stackoverflow.com/questions/767821/is-else-if-faster-than-switch-case
While the compiler can make some optimizations with switch statements, it does not implement hashes or lookup tables. Usually jump tables instead, but it is dependent on the compiler, the code, and its optimization settings.
+ 1
@Ace
So switch is actually faster with 5+ elements? :O