CODE GENERATION
Function
-CswMaxLF<number>
<number>: a number in the range of 0 - 100 denoting the maximum load factor
Backend-dependent
None
None
Allows changing the default strategy of the Compiler to use tables for switch statements.
Normally the Compiler uses a table for switches with more than about eight labels if the table is filled between 80% (minimum load factor of 80) and 100% (maximum load factor of 100). If there are not enough labels for a table or the table is not filled, a branch tree is generated (tree of if-else-if-else). This branch tree is like an `unrolled' binary search in a table which quickly evaluates the associated label for a switch expression.
Using a branch tree instead of a table improves code execution speed, but may increase code size. In addition, because the branch tree itself uses no special runtime routine for switch expression evaluation, debugging may be more seamless.
Specifying a load factor means that tables are generated in specific `fuel' status:
The table in the following listing is filled to 90% (labels for `0' to `9', except for `5').
switch(i) { case 0: ... case 1: ... case 2: ... case 3: ... case 4: ... // case 5: ... case 6: ... case 7: ... case 8: ... case 9: ... default }
Assumed that the minimum load factor is set to 50% and setting the maximum load factor for the above case to 80%, a branch tree is generated instead a table. But setting the maximum load factor to 95% produces a table.
To guarantee that tables are generated for switches with full tables only, set the table minimum and maximum load factors to 100:
-CswMinLF100 -CswMaxLF100.
Compiler options: