Skip to content

Commit

Permalink
refactor(model): Inline the graphForManager() function
Browse files Browse the repository at this point in the history
This simple map-lookup is only used once.

Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
  • Loading branch information
sschuberth committed Oct 2, 2024
1 parent 1e7ec04 commit ed4a537
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions model/src/main/kotlin/DependencyGraphNavigator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ class DependencyGraphNavigator(
"of them."
}

val graph = graphForManager(manager)
val graph = requireNotNull(graphs[manager]) {
"No DependencyGraph for package manager '$manager' available."
}

val rootDependencies = graph.scopes[DependencyGraph.qualifyScope(project, scopeName)].orEmpty().map { root ->
referenceFor(manager, root)
}
Expand Down Expand Up @@ -98,13 +101,6 @@ class DependencyGraphNavigator(
return dependencies
}

/**
* Return the [DependencyGraph] for the given [package manager][manager] or throw an exception if no such graph
* exists.
*/
private fun graphForManager(manager: String): DependencyGraph =
requireNotNull(graphs[manager]) { "No DependencyGraph for package manager '$manager' available." }

/**
* Resolve a [DependencyGraphNode] in the [DependencyGraph] for the specified [package manager][manager] with the
* given [pkgIndex] and [fragment]. Throw an exception if no such node can be found.
Expand Down

0 comments on commit ed4a537

Please sign in to comment.