You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
return executeEmergencyBreak() && someCondition; cannot be optimized to return someCondition && executeEmergencyBreak();, because the second piece of code will not trigger the emergency brake anymore, if someCondition is true.
Generally speaking, the re-ordering of expressions inside boolean operators is only allowed, if the short-circuit evaluation does not prohibit any side effects (that is any change of global state, like hitting the brakes) that would have occurred without the reordering.
Therefore this rule is only valid for methods that are known to have no side effect, but not for general Java methods being called.
The text was updated successfully, but these errors were encountered:
return executeEmergencyBreak() && someCondition;
cannot be optimized toreturn someCondition && executeEmergencyBreak();
, because the second piece of code will not trigger the emergency brake anymore, ifsomeCondition
is true.Generally speaking, the re-ordering of expressions inside boolean operators is only allowed, if the short-circuit evaluation does not prohibit any side effects (that is any change of global state, like hitting the brakes) that would have occurred without the reordering.
Therefore this rule is only valid for methods that are known to have no side effect, but not for general Java methods being called.
The text was updated successfully, but these errors were encountered: