Skip to content

Commit

Permalink
Store graph node for time improvement.
Browse files Browse the repository at this point in the history
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=129381085
  • Loading branch information
tadeegan authored and Dimitris Vardoulakis committed Aug 5, 2016
1 parent 0beeabb commit 3742118
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/com/google/javascript/jscomp/PureFunctionIdentifier.java
Expand Up @@ -25,7 +25,7 @@
import com.google.javascript.jscomp.CodingConvention.Cache;
import com.google.javascript.jscomp.DefinitionsRemover.Definition;
import com.google.javascript.jscomp.NodeTraversal.ScopedCallback;
import com.google.javascript.jscomp.graph.DiGraph;
import com.google.javascript.jscomp.graph.DiGraph.DiGraphNode;
import com.google.javascript.jscomp.graph.FixedPointGraphTraversal;
import com.google.javascript.jscomp.graph.FixedPointGraphTraversal.EdgeCallback;
import com.google.javascript.jscomp.graph.LinkedDirectedGraph;
Expand All @@ -35,7 +35,6 @@
import com.google.javascript.rhino.jstype.FunctionType;
import com.google.javascript.rhino.jstype.JSType;
import com.google.javascript.rhino.jstype.JSTypeNative;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
Expand Down Expand Up @@ -240,12 +239,12 @@ private static Collection<Definition> getCallableDefinitions(
*/
private void propagateSideEffects() {
// Nodes are function declarations; Edges are function call sites.
DiGraph<FunctionInformation, Node> sideEffectGraph =
LinkedDirectedGraph<FunctionInformation, Node> sideEffectGraph =
LinkedDirectedGraph.createWithoutAnnotations();

// create graph nodes
for (FunctionInformation functionInfo : functionSideEffectMap.values()) {
sideEffectGraph.createNode(functionInfo);
functionInfo.graphNode = sideEffectGraph.createNode(functionInfo);
}

// add connections to called functions and side effect root.
Expand Down Expand Up @@ -275,7 +274,7 @@ private void propagateSideEffects() {
Node defValue = def.getRValue();
FunctionInformation dep = functionSideEffectMap.get(defValue);
Preconditions.checkNotNull(dep);
sideEffectGraph.connect(dep, callSite, functionInfo);
sideEffectGraph.connect(dep.graphNode, callSite, functionInfo.graphNode);
}
}
}
Expand Down Expand Up @@ -811,6 +810,7 @@ private static boolean isCallOrApply(Node callSite) {
* list of calls that appear in a function's body.
*/
private static class FunctionInformation {
private DiGraphNode graphNode;
private List<Node> callsInFunctionBody = null;
private Set<Var> blacklisted = null;
private Set<Var> taintedLocals = null;
Expand Down
Expand Up @@ -19,7 +19,6 @@
import com.google.common.base.Preconditions;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
Expand Down Expand Up @@ -193,7 +192,7 @@ public GraphEdge<N, E> getFirstEdge(N n1, N n2) {
}

@Override
public GraphNode<N, E> createNode(N value) {
public DiGraphNode<N, E> createNode(N value) {
return createDirectedGraphNode(value);
}

Expand Down

0 comments on commit 3742118

Please sign in to comment.