Skip to content

Commit

Permalink
Improvements to Dagger BindingGraphConverter performance.
Browse files Browse the repository at this point in the history
RELNOTES=N/A

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=264471248
  • Loading branch information
bcorso authored and cpovirk committed Aug 21, 2019
1 parent 48db4f1 commit 86eb76f
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions java/dagger/internal/codegen/binding/BindingGraphConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
import dagger.model.DependencyRequest;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.HashSet;
import java.util.Set;
import javax.inject.Inject;
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.TypeElement;
Expand Down Expand Up @@ -105,6 +107,7 @@ private static MutableNetwork<Node, Edge> convert(
private final BindingDeclarationFormatter bindingDeclarationFormatter;
private final MutableNetwork<Node, Edge> network =
NetworkBuilder.directed().allowsParallelEdges(true).allowsSelfLoops(true).build();
private final Set<BindingNode> bindings = new HashSet<>();

/** Constructs a converter for a root (component, not subcomponent) binding graph. */
private Converter(BindingDeclarationFormatter bindingDeclarationFormatter) {
Expand Down Expand Up @@ -152,9 +155,11 @@ private void visitComponent(BindingGraph graph, ComponentNode parentComponent) {

for (ResolvedBindings resolvedBindings : graph.resolvedBindings()) {
for (BindingNode binding : bindingNodes(resolvedBindings)) {
network.addNode(binding);
for (DependencyRequest dependencyRequest : binding.dependencies()) {
addDependencyEdges(binding, dependencyRequest);
if (bindings.add(binding)) {
network.addNode(binding);
for (DependencyRequest dependencyRequest : binding.dependencies()) {
addDependencyEdges(binding, dependencyRequest);
}
}
if (binding.kind().equals(SUBCOMPONENT_CREATOR)
&& binding.componentPath().equals(currentComponent.componentPath())) {
Expand Down

0 comments on commit 86eb76f

Please sign in to comment.