Node tryOptimizeBlock ( Node n ) { // Remove any useless children for ( Node c = n . getFirstChild ( ) ; c != null ; ) { Node next = c . getNext ( ) ; // save c.next, since 'c' may be removed if ( ! isUnremovableNode ( c ) && ! mayHaveSideEffects ( c ) ) { checkNormalization ( ! NodeUtil . isFunctionDeclaration ( n ) , "function declaration" ) ; // TODO(johnlenz): determine what this is actually removing. Candidates // include: EMPTY nodes, control structures without children // (removing infinite loops), empty try blocks. What else? n . removeChild ( c ) ; reportChangeToEnclosingScope ( n ) ; markFunctionsDeleted ( c ) ; } else { tryOptimizeConditionalAfterAssign ( c ) ; } c = next ; } if ( n . isSyntheticBlock ( ) || n . isScript ( ) || n . getParent ( ) == null ) { return n ; } // Try to remove the block. Node parent = n . getParent ( ) ; if ( NodeUtil . tryMergeBlock ( n , false ) ) { reportChangeToEnclosingScope ( parent ) ; return null ; } return n ; }
Try removing unneeded block nodes and their useless children