fix(compiler): Fix search for one element cycles (#797)

This commit is contained in:
InversionSpaces 2023-07-14 14:06:21 +02:00 committed by GitHub
parent 0f9c40e9d1
commit 33ab33d4c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -40,12 +40,10 @@ object Linker extends Logging {
case path :: otherPaths => case path :: otherPaths =>
val pathDeps = deps.get(path.last).toList.flatten val pathDeps = deps.get(path.last).toList.flatten
val cycles = pathDeps.flatMap(dep => val cycles = pathDeps.flatMap(dep =>
NonEmptyChain NonEmptyChain.fromChain(
.fromChain( // This is slow
// This is slow path.toChain.dropWhile(_ != dep)
path.toChain.dropWhile(_ != dep) )
)
.toList
) )
val newPaths = pathDeps val newPaths = pathDeps
.filterNot(visited.contains) .filterNot(visited.contains)
@ -62,7 +60,7 @@ object Linker extends Logging {
.flatMap(m => .flatMap(m =>
findCycles( findCycles(
paths = NonEmptyChain.one(m.id) :: Nil, paths = NonEmptyChain.one(m.id) :: Nil,
visited = Set.empty, visited = Set(m.id),
result = List.empty result = List.empty
) )
) )