When programming, I usually deal with two sets of conditions combined together, for example:
if (A && B){...}
else if (!A && B){...}
else if (A && !B){...}
else if (!A && !B){...}
It can also be resolved using nested if statements.
if (A){
if (B) {...}
else {...}
}
else {
if (B) {...}
else {...}
}
EDIT: Some new thoughts about which I first evaluate both A and B and save them as a temporary variable (then do as the first approach) if evaluating A and B does not have a side effect?
So my question is, is there a difference in performance between the two and how is their readability?
I am C ++ code, if any.
source
share