When transforming a large amount of possible values, into different values, where you could use a table, or a large switch case statement, which would give the most efficient result? Will the compiler generate an optimal table automatically? Is there a limit to how much case statements there can be in the switch (I mean, a limit after which the compiler would generate hundreds of branch operations instead)? Also, do compilers always generate tables of function pointers to execute the case statements, or can they also generate simple lookup tables if all you do in the switch case statement is return values? How intelligent are compilers nowadays?
I'm interested in this both for C++ and for Java.
Thanks!