I have an enum and a switch statement using some of the enum entries but not all and they are currently out of order too, i.e. I have the following:
enum prot_tun_stat_e {
STAT_A = 0,
STAT_B,
STAT_C,
STAT_D,
STAT_E,
STAT_F, //5
STAT_G,
STAT_H,
STAT_I,
STAT_Y,
STAT_K, //10
STAT_COUNT //must be last
} __attribute__((packed));
and then I have a switch using the following entries:
switch(var) {
case C:
break;
case D:
break
case F:
break
case G:
break
default
}
and I was wondering if I better rearranged the items in the enum to be C=1,D=2,F=3&G=4
? Would that be more efficient?
Thanks, Ron
Platform: PowerPC
, compiler diab
var
against the numbers 1, 2, 3 and 4 would be more efficient than testing it against the numbers 2, 3, 5 and 6? I would be very surprised if it made the tiniest bit of difference.