Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Compile with clang -O2 -S. Observe that both versions of the function have identical x86 assembly code. */
- #include <stdio.h>
- typedef enum { APPLE, BANANA, PEAR, ORANGE, PEACH, CHERRY } Fruit;
- void with_switch(Fruit x)
- {
- switch (x) {
- case APPLE: case ORANGE: case BANANA: puts("ok");
- }
- }
- void with_if(Fruit x)
- {
- if (x == APPLE || x == ORANGE || x == BANANA) puts("ok");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement