Skip to content

Commit

Permalink
Avoid making unnecessary array copy.
Browse files Browse the repository at this point in the history
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=148459668
  • Loading branch information
brad4d authored and Tyler Breisacher committed Feb 27, 2017
1 parent 8384981 commit 5ed98ed
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions src/com/google/javascript/jscomp/InlineSimpleMethods.java
Expand Up @@ -19,9 +19,7 @@
import com.google.javascript.jscomp.NodeTraversal.Callback;
import com.google.javascript.rhino.IR;
import com.google.javascript.rhino.Node;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

Expand Down Expand Up @@ -210,18 +208,15 @@ private static Node getMethodBlock(Node fn) {
return expectedBlock.isNormalBlock() ? expectedBlock : null;
}

/**
* Given a set of method definitions, verify they are the same.
*/
private boolean allDefinitionsEquivalent(
Collection<Node> definitions) {
List<Node> list = new ArrayList<>();
list.addAll(definitions);
Node node0 = list.get(0);
for (int i = 1; i < list.size(); i++) {
if (!compiler.areNodesEqualForInlining(list.get(i), node0)) {
/** Given a set of method definitions, verify they are the same. */
private boolean allDefinitionsEquivalent(Collection<Node> definitions) {
Node first = null;
for (Node n : definitions) {
if (first == null) {
first = n;
} else if (!compiler.areNodesEqualForInlining(first, n)) {
return false;
}
} // else continue
}
return true;
}
Expand Down

0 comments on commit 5ed98ed

Please sign in to comment.