vendredi 27 mars 2015

Are there any compilers that will turn an else-if cascade into a switch?


I don't like switch in C and its descendants. Maybe its the need for a break or the clumsiness of the syntax requiring a shifting of mental gears, I don't know.


Whatever the reason, I will almost always write a sequence of else-if conditions examining the same variable rather than write a switch.


I see from http://ift.tt/1ICPGCZ that switch is more efficient in most cases and it got me wondering...


Are there any compilers (for any language) that will detect a number of else-if conditions on the same value and internally re-write it into a switch?





Aucun commentaire:

Enregistrer un commentaire