Hi Experts,
What is the key difference between if/else and swtich case statements ?
How the modern ARM GCC compilers handles it ?
Hello,
the most important difference would be the order of which predicates are evaluated.
As for the switch, the evaluations are done at the same, that is, there is no priority.
And the execution time will be the same for any conditions.
As for the if, the evaluations are done in order.
And the execution time will depend on the timing when the condition matches in the if-then-else statement.
If the conditions of if and else are exclusive, the if can be replaced with the switch.
Best regards,
Yasuhiko Koumoto.