From f1f37fcd74c3b8a88909b5ddfe4d7dcca03d5d96 Mon Sep 17 00:00:00 2001 From: yairm210 Date: Tue, 5 Nov 2024 14:48:54 +0200 Subject: [PATCH] Don't allocate memory until you have to --- core/src/com/unciv/logic/map/tile/Tile.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/com/unciv/logic/map/tile/Tile.kt b/core/src/com/unciv/logic/map/tile/Tile.kt index be3a1924ef..31d990e7d4 100644 --- a/core/src/com/unciv/logic/map/tile/Tile.kt +++ b/core/src/com/unciv/logic/map/tile/Tile.kt @@ -366,8 +366,8 @@ class Tile : IsPartOfGameInfoSerialization, Json.Serializable { fun isRoughTerrain() = allTerrains.any { it.isRough() } - @Transient - private val stateThisTile: StateForConditionals = StateForConditionals(tile = this) + @delegate:Transient + private val stateThisTile: StateForConditionals by lazy { StateForConditionals(tile = this) } /** Checks whether any of the TERRAINS of this tile has a certain unique */ fun terrainHasUnique(uniqueType: UniqueType, state: StateForConditionals = stateThisTile) = terrainUniqueMap.getMatchingUniques(uniqueType, state).any()