View Single Post
  #1   Spotlight this post!  
Unread 20-01-2008, 21:15
evan_wilson's Avatar
evan_wilson evan_wilson is offline
QUARK
AKA: Evan Wilson
FRC #2172 (Street Legal)
Team Role: Programmer
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Elyria, OH
Posts: 15
evan_wilson is an unknown quantity at this point
Send a message via AIM to evan_wilson Send a message via Yahoo to evan_wilson
Unhappy 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!