If I have some code with up to 9 if statements in some of my methods and all most all of them will intrinsically only meet one of the if requirements, would using else if speed my code up?
For example, if I had this
if (x == 1){
do something;
}
if (x == 2){
do something;
}
if (x == 3){
do something;
}
if (x == 4){
do something;
}
Would changing it to this speed up the code?
if (x == 1){
do something;
}
else if (x == 2){
do something;
}
else if (x == 3){
do something;
}
else if (x == 4){
do something;
}
In my actual code the if statements are evaluating more complex stuff than integers.