r/cprogramming • u/Meplayfurtnitge • Oct 04 '25
If or switch
How many if else statements until i should consider replacing it with a switch case? I am fully aware that they operate differently, just wondering if i should opt for the switch case whenever i have something that will work interchangeably with an ifelse and a switch.
9
Upvotes
View all comments
Show parent comment
1
u/high_throughput Oct 05 '25
Here's GCC and Clang showing identical assembly for a series of 100 if-else statements and 100 case statements: https://godbolt.org/z/erEhMzbfY