From 14115cdea7bd3b4902179de71a1b096d7175ebdb Mon Sep 17 00:00:00 2001 From: yairm210 Date: Mon, 16 Sep 2024 04:13:33 +0300 Subject: [PATCH] Revert "perf: minor speedup in distance to tiles" This reverts commit f78fbfd22d422b251dcd737faeb11e34e7158a2f. --- core/src/com/unciv/logic/map/mapunit/movement/UnitMovement.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core/src/com/unciv/logic/map/mapunit/movement/UnitMovement.kt b/core/src/com/unciv/logic/map/mapunit/movement/UnitMovement.kt index fc5cb73b00..26808a0f43 100644 --- a/core/src/com/unciv/logic/map/mapunit/movement/UnitMovement.kt +++ b/core/src/com/unciv/logic/map/mapunit/movement/UnitMovement.kt @@ -69,8 +69,7 @@ class UnitMovement(val unit: MapUnit) { } } - val currentBestPath = distanceToTiles[neighbor] - if (currentBestPath == null || currentBestPath.totalDistance > totalDistanceToTile) { // this is the new best path + if (!distanceToTiles.containsKey(neighbor) || distanceToTiles[neighbor]!!.totalDistance > totalDistanceToTile) { // this is the new best path val usableMovement = if (includeOtherEscortUnit && unit.isEscorting()) minOf(unitMovement, unit.getOtherEscortUnit()!!.currentMovement) else unitMovement