Skip to content

Commit

Permalink
fixed files form Closure #116
Browse files Browse the repository at this point in the history
  • Loading branch information
tdurieux committed Mar 7, 2017
1 parent cfdbf5d commit fc94340
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,15 @@ private CanInlineResult canInlineReferenceDirectly(

Node block = fnNode.getLastChild();

boolean hasSideEffects = false; // empty function case
if (block.hasChildren()) {
Preconditions.checkState(block.hasOneChild());
Node stmt = block.getFirstChild();
if (stmt.isReturn()) {
hasSideEffects = NodeUtil.mayHaveSideEffects(
stmt.getFirstChild(), compiler);
}
}

// CALL NODE: [ NAME, ARG1, ARG2, ... ]
Node cArg = callNode.getFirstChild().getNext();
Expand All @@ -720,6 +729,9 @@ private CanInlineResult canInlineReferenceDirectly(
// For each named parameter check if a mutable argument use more than one.
if (fnParam != null) {
if (cArg != null) {
if (hasSideEffects && NodeUtil.canBeSideEffected(cArg)) {
return CanInlineResult.NO;
}

// Check for arguments that are evaluated more than once.
// Note: Unlike block inlining, there it is not possible that a
Expand Down

0 comments on commit fc94340

Please sign in to comment.