The compiler will generate a jump table when possible, but sometimes the case values are too far apart, or to few, to create a useful jump table.
The following (useless) function will generate a jump table:
int sample1(int n)
{
switch (n)
{
case 1: return sample2(10);
case 2: return sample2(20);
case 4: return sample2(40);
case 5: return sample2(50);
default: return 0;
}
}
Pelle