@ Override @ SuppressWarnings ( "fallthrough" ) public Node optimizeSubtree ( Node node ) { switch ( node . getToken ( ) ) { case THROW : case RETURN : { Node result = tryRemoveRedundantExit ( node ) ; if ( result != node ) { return result ; } return tryReplaceExitWithBreak ( node ) ; } // TODO(johnlenz): Maybe remove redundant BREAK and CONTINUE. Overlaps // with MinimizeExitPoints. case NOT : tryMinimizeCondition ( node . getFirstChild ( ) ) ; return tryMinimizeNot ( node ) ; case IF : performConditionSubstitutions ( node . getFirstChild ( ) ) ; return tryMinimizeIf ( node ) ; case EXPR_RESULT : performConditionSubstitutions ( node . getFirstChild ( ) ) ; return tryMinimizeExprResult ( node ) ; case HOOK : performConditionSubstitutions ( node . getFirstChild ( ) ) ; return tryMinimizeHook ( node ) ; case WHILE : case DO : tryMinimizeCondition ( NodeUtil . getConditionExpression ( node ) ) ; return node ; case FOR : tryJoinForCondition ( node ) ; tryMinimizeCondition ( NodeUtil . getConditionExpression ( node ) ) ; return node ; case BLOCK : return tryReplaceIf ( node ) ; default : return node ; //Nothing changed } }
Tries to apply our various peephole minimizations on the passed in node .