Skip to content

Commit

Permalink
Improved code quality using map function
Browse files Browse the repository at this point in the history
  • Loading branch information
smilefx committed May 13, 2024
1 parent 7520959 commit 1f8f7f3
Showing 1 changed file with 2 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,8 @@ fun loadSegments(

// Load Blocks and save in cache for each map file name
simulationRunsWrapperList.forEach {
// Check if static blocks for static map file name are already loaded
if (!staticBlockCache.containsKey(it.mapDataFile.toString())) {
// Load blocks and save in cache
staticBlockCache[it.mapDataFile.toString()] = loadBlocks(it.mapDataFile).toList()
}

// Set blocks for current simulationRunsWrapper from the 'cache'
it.blocks = staticBlockCache[it.mapDataFile.toString()]!!
it.blocks =
staticBlockCache.getOrPut(it.mapDataFile.toString()) { loadBlocks(it.mapDataFile).toList() }
}

// Holds the [ArrayDeque] of [CarlaSimulationRunsWrapper] from the parameters
Expand Down

0 comments on commit 1f8f7f3

Please sign in to comment.