Skip to content

Commit

Permalink
fix: skip deep comparison for Gradle projects
Browse files Browse the repository at this point in the history
This is unnecessary and leads to a long runtime (and possible an
infinite loop/recusrsion) for large dependency graphs as observed in
oss-review-toolkit#9763
  • Loading branch information
jjohannes committed Jan 23, 2025
1 parent 1d9c9c8 commit ee5d2b5
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions model/src/main/kotlin/utils/DependencyGraphBuilder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,12 @@ class DependencyGraphBuilder<D>(
val dependencies2 = dependencies.associateBy { dependencyHandler.identifierFor(it) }
if (!dependencies2.keys.containsAll(dependencies1)) return false

if (dependencyHandler::class.simpleName == "GradleDependencyHandler") {
// In case of Gradle, we can skip the costly deep comparison.
// If the dependencies are the same, their children are also the same.
if (dependencies2.keys.sorted() == dependencies1.sorted()) return true
}

return ref.dependencies.all { refDep ->
dependencies2[dependencyIds[refDep.pkg]]?.let { dependencyTreeEquals(refDep, it) } == true
}
Expand Down

0 comments on commit ee5d2b5

Please sign in to comment.