Skip to content

Commit ab535d6

Browse files
committed
chore(model): Drop unnecessary checks for visited nodes
When building the dependency graph out of the structure of `DependencyReference` objects, it is not necessary to test whether a node has already been visited. The way the structure has been created ensures that it is free of cycles. Signed-off-by: Oliver Heger <oliver.heger@bosch.com>
1 parent 8311b15 commit ab535d6

1 file changed

Lines changed: 2 additions & 6 deletions

File tree

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -504,17 +504,13 @@ private fun Collection<DependencyReference>.toGraph(
504504
}
505505

506506
private fun Collection<DependencyReference>.visitEach(visit: (ref: DependencyReference) -> Unit) {
507-
val visited = mutableSetOf<NodeKey>()
508507
val queue = LinkedList(this)
509508

510509
while (queue.isNotEmpty()) {
511510
val ref = queue.removeFirst()
512511

513-
if (ref.key !in visited) {
514-
visit(ref)
515-
visited += ref.key
516-
queue += ref.dependencies
517-
}
512+
visit(ref)
513+
queue += ref.dependencies
518514
}
519515
}
520516

0 commit comments

Comments
 (0)