Hello,

I've always thought that switch statements were syntatic sugar for if-then-else
statements, but when debugging, I've come to the conclusion that switch statements
perform better than if-then-else statements. Here's some code to
illustrate:
Code:
int main()
{
  int a;

  a = 5;

  switch(a)
  {
    case 2:
      printf("2\n");
      break;

    case 3:
      printf("3\n");
      break;

    case 4:
      printf("4\n");
      break;
      
    case 5: 
      printf("5\n");
      break;
  }
      
  return 0;
}
Putting a breakpoint on the line with a = 5, and stepping through the code, I
get to the line with the switch statement and then immediately to the last case
statement.
Is the debugger playing tricks with me? Or are case statements implemented with
some sort of indexing scheme? I'm using gcc and gdb.

Thanks.