From e92edf6bf60d9a30e39579bae23ae0f4dd5c9254 Mon Sep 17 00:00:00 2001 From: bcorso Date: Thu, 5 Sep 2019 12:43:15 -0700 Subject: [PATCH] Dagger performance improvements. Memoization speeds up Dagger processing by 14% and speeds up overall build time by 5%. RELNOTES=Minor improvements to Dagger build performance. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=267430637 --- .../dagger/internal/codegen/binding/BindingGraph.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/java/dagger/internal/codegen/binding/BindingGraph.java b/java/dagger/internal/codegen/binding/BindingGraph.java index 33a5c8f9a09..7659dc0b7e4 100644 --- a/java/dagger/internal/codegen/binding/BindingGraph.java +++ b/java/dagger/internal/codegen/binding/BindingGraph.java @@ -172,12 +172,17 @@ public ImmutableSet componentRequirements() { private ImmutableSet requiredModuleElements() { return stream(SUBGRAPH_TRAVERSER.depthFirstPostOrder(this)) - .flatMap(graph -> graph.contributionBindings().values().stream()) + .flatMap(graph -> graph.bindingModules().stream()) + .filter(ownedModuleTypes()::contains) + .collect(toImmutableSet()); + } + + @Memoized + protected ImmutableSet bindingModules() { + return contributionBindings().values().stream() .flatMap(bindings -> bindings.contributionBindings().stream()) .map(ContributionBinding::contributingModule) - .distinct() .flatMap(presentValues()) - .filter(ownedModuleTypes()::contains) .collect(toImmutableSet()); }