-
Best way
Hey Guys
I was wondering what would be the best way of doing something in you opinion
i want to carry out code if depending on the value of two variables so i don't knwo wether nested case statements or 2 stament if staments would be better.
so i would have
switch(I)
{
case 0:
{
switch (d)
etc
or
if ((d == 0) && (i = 0))
i am currently doing it with ifs but is thsi teh best way to do it i meean which way is more efficent.
Cheers
Peter
-
I don't think there's any difference in the generated code between a switch and a list of else ifs. However, using two switches will generate two if's, rather than a boolean operator and another if. Not sure on the clock timings for those though.
-
Optimization
To do an else if with a one liner statement, its better to do it in if-form because with the switch statement, you need a break; clause.