Skip to content

Commit 42c4d5e

Browse files
fviernausschuberth
authored andcommitted
refactor(model): Initialize the queue in one line
Signed-off-by: Frank Viernau <[email protected]>
1 parent 829f6ac commit 42c4d5e

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

model/src/main/kotlin/DependencyNavigator.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,9 @@ private data class QueueItem(
187187
private fun getShortestPathsForScope(nodes: Sequence<DependencyNode>): Map<Identifier, List<Identifier>> {
188188
// A node is visited if and only if it is a key in this map.
189189
val predecessorForVisitedNode = mutableMapOf<DependencyNode, DependencyNode?>()
190-
val queue = LinkedList<QueueItem>()
191190
// Keep track of the end-points of the shortest paths to speed up the re-construction.
192191
val firstVisitedNodeForId = mutableMapOf<Identifier, DependencyNode>()
193-
194-
nodes.forEach { queue.offer(QueueItem(it.getStableReference(), null)) }
192+
val queue = nodes.mapTo(LinkedList()) { QueueItem(it.getStableReference(), null) }
195193

196194
while (queue.isNotEmpty()) {
197195
val item = queue.poll()

0 commit comments

Comments
 (0)