Reapply "perf: minor speedup in distance to tiles"

This reverts commit 14115cdea7.
This commit is contained in:
yairm210 2024-09-16 04:29:55 +03:00
parent 0e612ac574
commit c487a64ba8

View File

@ -70,7 +70,8 @@ class UnitMovement(val unit: MapUnit) {
}
}
if (!distanceToTiles.containsKey(neighbor) || distanceToTiles[neighbor]!!.totalDistance > totalDistanceToTile) { // this is the new best path
val currentBestPath = distanceToTiles[neighbor]
if (currentBestPath == null || currentBestPath.totalDistance > totalDistanceToTile) { // this is the new best path
val usableMovement = if (includeOtherEscortUnit && unit.isEscorting())
minOf(unitMovement, unit.getOtherEscortUnit()!!.currentMovement)
else unitMovement