3 ms·
For more than a few cases in the switch: If the case values are dense (such as just the integers from 0 to 9), the compiler will turn it into a jump table. ht
by anon946 6y ago
For more than a few cases in the switch:
If the case values are dense (such as just the integers from 0 to 9), the compiler will turn it into a jump table.
https://godbolt.org/z/1Khahr https://godbolt.org/z/1Khahr
If too sparse for jump table, then typically will be turned into a binary search tree.