Skip to content

Commit

Permalink
Change ComponentTreeDepsIrCreator to use linkedSetOf instead of mutab…
Browse files Browse the repository at this point in the history
…leSetOf.

This isn't a functional change since mutableSetOf returns a LinkedHashSet, but it's better to be explicit about it since we depend on the order.

RELNOTES=N/A
PiperOrigin-RevId: 409012506
  • Loading branch information
bcorso authored and Dagger Team committed Nov 11, 2021
1 parent 2fa9aa7 commit 3703588
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,10 @@ class ComponentTreeDepsIrCreator private constructor(
val globalEntryPointsByComponent = aggregatedDeps
.filter { it.test == null && it.module == null }
.groupBy(keySelector = { it.test }, valueTransform = { it.fqName })
val result = mutableMapOf<ClassName, MutableSet<ClassName>>()
val result = mutableMapOf<ClassName, LinkedHashSet<ClassName>>()
aggregatedRoots.forEach { aggregatedRoot ->
if (!rootsUsingSharedComponent.contains(aggregatedRoot.root)) {
result.getOrPut(aggregatedRoot.root) { mutableSetOf() }.apply {
result.getOrPut(aggregatedRoot.root) { linkedSetOf() }.apply {
addAll(globalModules)
addAll(globalEntryPointsByComponent.values.flatten())
addAll(testDepsByRoot.getOrElse(aggregatedRoot.root) { emptyList() })
Expand All @@ -145,13 +145,13 @@ class ComponentTreeDepsIrCreator private constructor(
}
// Add the Default/EarlyEntryPoint root if necessary.
if (rootsUsingSharedComponent.isNotEmpty()) {
result.getOrPut(DEFAULT_ROOT_CLASS_NAME) { mutableSetOf() }.apply {
result.getOrPut(DEFAULT_ROOT_CLASS_NAME) { linkedSetOf() }.apply {
addAll(globalModules)
addAll(globalEntryPointsByComponent.values.flatten())
addAll(rootsUsingSharedComponent.flatMap { testDepsByRoot.getOrElse(it) { emptyList() } })
}
} else if (hasEarlyEntryPoints) {
result.getOrPut(DEFAULT_ROOT_CLASS_NAME) { mutableSetOf() }.apply {
result.getOrPut(DEFAULT_ROOT_CLASS_NAME) { linkedSetOf() }.apply {
addAll(globalModules)
addAll(
globalEntryPointsByComponent.entries
Expand Down

0 comments on commit 3703588

Please sign in to comment.