Hi All
Consult a while, has any tips can speed the judgment of"Switch case" in keil c??
Seem to make the common use parameter putting the front to judge first ??
For examples,if c equal one more then equal two
so we can write down like this
switch(c) { case 1: break; case 2: break; }
an we don't use this type
switch(c) { case 2 break; case 1 break; }
Is any tips like this can use in "switch case" in keil c??
Sorry for my poor english^^"""
Thanks
Thanks all
I just want to know
1 how is ccase realy do??
2 how can we write the correct code to help complier to output great code
3 how to write my own if-then-else chain or others ?? is any example code??
for now,it seem look like the parameter of switch
is much better in order and closed
CODE1
#define AA 0 #define BB 1 #define CC 2 ~ #define ZZ 26 switch(c) { case AA: break; ~ case ZZ: break; }
CODE2
#define AA 0 #define BB 10 #define CC 20 ~ #define ZZ 255 switch(c) { case DD: break; ~ case GG: break; case MM: break; }
if the value of c is form AA to ZZ ,The code1 speed is faster then the code2 in optimizer level 7
thanks a again