diff --git a/stars-importer-carla/src/main/kotlin/tools/aqua/stars/importer/carla/carlaDataFileHandling.kt b/stars-importer-carla/src/main/kotlin/tools/aqua/stars/importer/carla/carlaDataFileHandling.kt index bb9417a4..9430b922 100644 --- a/stars-importer-carla/src/main/kotlin/tools/aqua/stars/importer/carla/carlaDataFileHandling.kt +++ b/stars-importer-carla/src/main/kotlin/tools/aqua/stars/importer/carla/carlaDataFileHandling.kt @@ -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