Skip to content

Commit 86d09b3

Browse files
jjohannessschuberth
authored andcommitted
fix(DependencyGraphBuilder): Skip deep comparison for Gradle projects
This is unnecessary and leads to a long runtime (and possible an infinite loop / recursion) for large dependency graphs as observed in Signed-off-by: Jendrik Johannes <[email protected]>
1 parent 1d9c9c8 commit 86d09b3

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

model/src/main/kotlin/utils/DependencyGraphBuilder.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,13 @@ class DependencyGraphBuilder<D>(
335335
val dependencies2 = dependencies.associateBy { dependencyHandler.identifierFor(it) }
336336
if (!dependencies2.keys.containsAll(dependencies1)) return false
337337

338+
// It is not possible to check for the class instance here as the type comes from a plugin.
339+
if (dependencyHandler.javaClass.simpleName == "GradleDependencyHandler") {
340+
// In case of Gradle, the costly deep comparison can be skipped, because if the dependencies are the same,
341+
// their children are also the same.
342+
if (dependencies2.keys == dependencies1.toSet()) return true
343+
}
344+
338345
return ref.dependencies.all { refDep ->
339346
dependencies2[dependencyIds[refDep.pkg]]?.let { dependencyTreeEquals(refDep, it) } == true
340347
}

0 commit comments

Comments
 (0)