Reputation: 21
I need answer for one of the most debated C-question.
Upvotes: 1
Views: 105
Reputation: 1069
1 If you have only an if else
structure it does not matter because the condition is checked anyway.
2 if you have if
followed by some else if
s and the conditions inside them require function calls and/or many computations you should think of ordering your cases from most frequent to least to avoid some of the computations.
Unless the priority of the checks matters!
Upvotes: 1
Reputation: 262534
I would 100% go for clarity of the code here. For example by avoiding double negatives (which you could get by swapping the conditions for the two branches).
Any performance difference will be totally negligable.
Upvotes: 3