switch vs. if... else if. More efficient?
Greetings!
I'm programming the code for the CMUCam and serial interface right now and have just begun the portion where I determine the kind of data I am getting from the serial port buffer. I can imagine that this is an intensive process on the controller... so:
would it be more efficient to use a switch statement or an else... else if chain to determine what the next character in the buffer is?
I've read that a switch statement (out of many possibilities) would be more efficient because of compiler's ability to optimize the order of comparisons. But does this apply in the case of C18 2.4?
Thank you!
|