Optimize switch case ranges to use mapping lookup in the case where all ranges are a small number of integers.
Consider the code:
switch(expr) {
case 0..3:
/* Foo */
break;
default:
/* Bar */
break;
}
If all ranges are integers, the above can be converted into:
case 0: case 1: case 2: case 3:
/* Foo */
break;
default:
/* Bar */
break;
Which will cause it to use mapping lookup tables (cf #10125 (closed)).
Note that this is only a valid optimization when the number of elements of the resulting mapping does not grow excessively. A reasonable growth factor limit is probably on the order of 16
.
Edited by Henrik (Grubba) Grubbström