@@ -608,7 +608,7 @@ ControlFlowNode guardNode(ConditionBlock conditionBlock, boolean flipped) {
608608 // if a guard node is compared to a boolean literal,
609609 // the other operand is also a guard node,
610610 // but with polarity depending on the literal (and on the comparison).
611- exists ( CompareNode cmpNode , Cmpop op , ControlFlowNode b , boolean bool |
611+ exists ( CompareNode cmpNode , Cmpop op , ControlFlowNode b , boolean should_flip |
612612 (
613613 cmpNode .operands ( result , op , b ) or
614614 cmpNode .operands ( b , op , result )
@@ -617,19 +617,19 @@ ControlFlowNode guardNode(ConditionBlock conditionBlock, boolean flipped) {
617617 (
618618 // comparing to the boolean
619619 ( op instanceof Eq or op instanceof Is ) and
620- // `bool` is the value being compared against, here the value of `b`
621- b .getNode ( ) .( BooleanLiteral ) .booleanValue ( ) = bool
620+ // we shoould flip if the value compared against, here the value of `b`, is false
621+ should_flip = b .getNode ( ) .( BooleanLiteral ) .booleanValue ( ) . booleanNot ( )
622622 or
623623 // comparing to the negation of the boolean
624624 ( op instanceof NotEq or op instanceof IsNot ) and
625- // again, `bool` is the value being compared against, but here it is the value of `not b`
626- b .getNode ( ) .( BooleanLiteral ) .booleanValue ( ) = bool .booleanNot ( )
625+ // again, we should flip if the value compared against, here the value of `not b`, is false.
626+ // That is, if the value of `b` is true.
627+ should_flip = b .getNode ( ) .( BooleanLiteral ) .booleanValue ( )
627628 )
628629 |
629- // if `bool` is true, we should preserve `flipped`, otherwise we should flip it
630- // `flipped xor (not bool)` achieves that.
630+ // we flip `flipped` according to `should_flip` via the formula `flipped xor should_flip`.
631631 flipped in [ true , false ] and
632- cmpNode = guardNode ( conditionBlock , flipped .booleanXor ( bool . booleanNot ( ) ) )
632+ cmpNode = guardNode ( conditionBlock , flipped .booleanXor ( should_flip ) )
633633 )
634634}
635635
0 commit comments