Skip to content

Commit a3c19f7

Browse files
committed
fix: 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 #9763 Signed-off-by: Jendrik Johannes <[email protected]>
1 parent 1d9c9c8 commit a3c19f7

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

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

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

338+
if (dependencyHandler::class.simpleName == "GradleDependencyHandler") {
339+
// In case of Gradle, we can skip the costly deep comparison.
340+
// If the dependencies are the same, their children are also the same.
341+
if (dependencies2.keys.sorted() == dependencies1.sorted()) return true
342+
}
343+
338344
return ref.dependencies.all { refDep ->
339345
dependencies2[dependencyIds[refDep.pkg]]?.let { dependencyTreeEquals(refDep, it) } == true
340346
}

0 commit comments

Comments
 (0)