Hi,
In simple cases like linear sequences, will the GCC compiler make a jump
table?
switch (x) {
case 0:
case 1:
case 2:
case 3:
}
In all other cases where a jump table is not applicable, will the GCC compiler
sort the values and do a binary search?
switch (x) {
case 1:
case 256:
case 65536:
case 512:
}
The reason for asking is that some time back I looked at the output from GCC
3.4 in a complicated switch statement and the outputting code did nothing
more than compare against all the values in the switch statement. This of
course was O(N) instead of O(log2(N)).
--HPS
PS: Please CC me hence I am not on this list.