From ac8648216ec769f62e64e8cbde5759a196893aa6 Mon Sep 17 00:00:00 2001 From: SomeTroglodyte <63000004+SomeTroglodyte@users.noreply.github.com> Date: Thu, 16 Apr 2020 19:39:45 +0200 Subject: [PATCH] Tiny optimization for isCoastalTile (#2434) Yes benefit may be low as neighbors are already cached, but cost is negligible --- core/src/com/unciv/logic/map/TileInfo.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/src/com/unciv/logic/map/TileInfo.kt b/core/src/com/unciv/logic/map/TileInfo.kt index 8af960da..fa1e7732 100644 --- a/core/src/com/unciv/logic/map/TileInfo.kt +++ b/core/src/com/unciv/logic/map/TileInfo.kt @@ -292,7 +292,9 @@ open class TileInfo { fun hasImprovementInProgress() = improvementInProgress!=null - fun isCoastalTile() = neighbors.any { it.baseTerrain==Constants.coast } + @delegate:Transient + private val _isCoastalTile: Boolean by lazy { neighbors.any { it.baseTerrain==Constants.coast } } + fun isCoastalTile() = _isCoastalTile fun hasViewableResource(civInfo: CivilizationInfo): Boolean = resource != null && (getTileResource().revealedBy == null || civInfo.tech.isResearched(getTileResource().revealedBy!!))