From ed665c193bc83ff98320fc1c1eff26767e49f907 Mon Sep 17 00:00:00 2001 From: smilefx Date: Mon, 13 May 2024 20:10:27 +0200 Subject: [PATCH] Improved code quality using map function --- .../aqua/stars/importer/carla/carlaDataFileHandling.kt | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) 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