|
-
Sep 7th, 2001, 09:29 AM
#1
Thread Starter
Lively Member
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
"Let's all join forces, rule with an iron hand...and prove to all the world, metal rules the land..."
-- Judas Priest
My email is [email protected]
-
Sep 7th, 2001, 10:23 AM
#2
Monday Morning Lunatic
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.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Sep 8th, 2001, 08:12 AM
#3
Lively Member
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|