3 ms·
JS's switch is a different beast. The OP's statement doesn't work in C/C++ because its case labels need to be unique. You also would need a large number of cas
by yvdriess 7y ago
JS's switch is a different beast. The OP's statement doesn't work in C/C++ because its case labels need to be unique.
You also would need a large number of case statements before a modern optimizing compiler will decide a switch statement is worth a jump table rather than conditionals.
- archi42 7y agoIn fact, the compiler building a static switch table from non-constant expressions sounds a little bit impossible ;-)