Skip to content

Commit

Permalink
core: stdcm: ignore paths that use the same block several times
Browse files Browse the repository at this point in the history
  • Loading branch information
eckter committed May 14, 2024
1 parent 4b097f8 commit 11f49d4
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ private class InfraExplorerImpl(
private val blockInfra: BlockInfra,
private var blocks: AppendOnlyLinkedList<BlockId>,
private var routes: AppendOnlyLinkedList<RouteId>,
private var blockRoutes: MutableMap<BlockId, MutableSet<RouteId>>,
private var blockRoutes: MutableMap<BlockId, RouteId>,
private var incrementalPath: IncrementalPath,
private var pathPropertiesCache: MutableMap<BlockId, PathProperties>,
private var currentIndex: Int = 0,
Expand Down Expand Up @@ -172,8 +172,7 @@ private class InfraExplorerImpl(
getCurrentBlock(),
)
}
val nonOverlappingRoutesOnBlock =
blockRoutes[getCurrentBlock()]!!.intersect(routes.toSet()).toList()
val nonOverlappingRoutesOnBlock = listOf(blockRoutes[getCurrentBlock()]!!)
val blockPathProperties = path.withRoutes(nonOverlappingRoutesOnBlock)
pathPropertiesCache[getCurrentBlock()] = blockPathProperties

Expand Down Expand Up @@ -275,6 +274,7 @@ private class InfraExplorerImpl(
val addedBlocks = mutableListOf<BlockId>()

for (block in routeBlocks) {
if (blockRoutes.containsKey(block)) return false // We already passed by this block
addedBlocks.add(block)
if (block == firstLocation?.edge) {
seenFirstBlock = true
Expand Down Expand Up @@ -308,7 +308,10 @@ private class InfraExplorerImpl(
assert(seenFirstBlock)
blocks.addAll(addedBlocks)
routes.add(route)
for (block in addedBlocks) blockRoutes.getOrPut(block) { mutableSetOf() }.add(route)
for (block in addedBlocks) {
assert(!blockRoutes.containsKey(block))
blockRoutes[block] = route
}
for (i in 0 ..< nBlocksToSkip) moveForward()
for (pathFragment in pathFragments) incrementalPath.extend(pathFragment)

Expand Down

0 comments on commit 11f49d4

Please sign in to comment.