From 7b4177d06baa63661f3c22e7bff3ba00be9def82 Mon Sep 17 00:00:00 2001 From: Sebastian Schuberth Date: Wed, 2 Oct 2024 14:21:09 +0200 Subject: [PATCH] refactor(model): Inline a `referenceFor()` overload function Only the version that takes a `rootIndex` is directly used. Signed-off-by: Sebastian Schuberth --- .../src/main/kotlin/DependencyGraphNavigator.kt | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/model/src/main/kotlin/DependencyGraphNavigator.kt b/model/src/main/kotlin/DependencyGraphNavigator.kt index 176e3950d802c..42c09b4479cb8 100644 --- a/model/src/main/kotlin/DependencyGraphNavigator.kt +++ b/model/src/main/kotlin/DependencyGraphNavigator.kt @@ -101,22 +101,16 @@ class DependencyGraphNavigator( return dependencies } - /** - * 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. - */ - private fun referenceFor(manager: String, pkgIndex: Int, fragment: Int): DependencyGraphNode = - requireNotNull(graphDependencyRefMappings[manager])[pkgIndex].find { it.fragment == fragment } - ?: throw IllegalArgumentException( - "Could not resolve a DependencyReference for index = $pkgIndex and fragment $fragment." - ) - /** * Resolve a [DependencyGraphNode] in the [DependencyGraph] for the specified [package manager][manager] that * corresponds to the given [rootIndex]. Throw an exception if no such reference can be found. */ private fun referenceFor(manager: String, rootIndex: RootDependencyIndex): DependencyGraphNode = - referenceFor(manager, rootIndex.root, rootIndex.fragment) + requireNotNull(graphDependencyRefMappings[manager])[rootIndex.root].find { it.fragment == rootIndex.fragment } + ?: throw IllegalArgumentException( + "Could not resolve a DependencyReference for index = ${rootIndex.root} and fragment " + + "${rootIndex.fragment}." + ) } /**