It depends on what exactly you are coding, because the compiler can optimize a switch easier than it can a bunch of if's, but you'll never notice that difference. If you want an increase and you can break the if's to perform similar to a binary search, you'll get a much better improvement.
Instead of:
if (a == 1)
else if (a == 2)
else if (a == 3)
else if (a == 4)
you can put
if (a <=2 )
if (a ==1)
else if (a == 2)
else
if (a == 3)
else if (a == 4)
The more choices there are the more the speedup will be. But be warned that your code becomes hard to read and debug, which is worse than running slow.
ObCircle2:
Now something about the coding... What will run faster a bunch of if's or
switch? :)
David!
+------------------------------------------------------------+
| Ensure that you have read the CircleMUD Mailing List FAQ: |
| http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
+------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/08/00 PST