I read on StackOverflow that using
if(someCondition)
{
someCode();
}
else
{
alternateCode();
}
can be inefficient due to susceptibility to branch misprediction (see this question for example).
So is a switch
-construct, e.g.,
switch (someCondition)
{
case (someCase):
something();
break;
case (otherCase):
someOtherInstructions();
break;
default:
defaultAction();
break;
}
any different in this respect (besides the fact that I have allowed for three possibilities)?