Skip to content

Commit ac35731

Browse files
committed
chore(model): Avoid value mapping by using a destination map
Signed-off-by: Sebastian Schuberth <[email protected]>
1 parent d8cbc46 commit ac35731

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ private enum class NodeColor { WHITE, GRAY, BLACK }
494494
* Finding a minimal solution is NP-complete.
495495
*/
496496
internal fun breakCycles(edges: Collection<DependencyGraphEdge>): Set<DependencyGraphEdge> {
497-
val outgoingEdgesForNodes = edges.groupBy({ it.from }, { it.to }).mapValues { it.value.toMutableSet() }
497+
val outgoingEdgesForNodes = edges.groupByTo(mutableMapOf(), { it.from }, { it.to })
498498
val color = outgoingEdgesForNodes.keys.associateWithTo(mutableMapOf()) { NodeColor.WHITE }
499499

500500
fun visit(u: Int) {

0 commit comments

Comments
 (0)