I was wondering if there was any difference in the way the following code was compiled into assembly. I've heard that switch-case is more efficient than if else, but in this example I am not quite sure if that would be the case.
if(x==1){
...
}else if(x==2){
...
}else{
...
}
and
switch(x){
case 1:
...
break;
case 2:
...
break;
default:
...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With