mirror of
https://github.com/yairm210/Unciv.git
synced 2025-02-20 19:56:51 +01:00
perf(cpu): Sequences, and initially set array list to desired size
This commit is contained in:
parent
1c25206dbb
commit
bdc5cd2ecf
|
|
@ -262,7 +262,7 @@ object NextTurnAutomation {
|
|||
}
|
||||
|
||||
val stateForConditionals = civInfo.state
|
||||
while(civInfo.tech.freeTechs > 0) {
|
||||
while (civInfo.tech.freeTechs > 0) {
|
||||
val costs = getGroupedResearchableTechs()
|
||||
if (costs.isEmpty()) return
|
||||
|
||||
|
|
|
|||
|
|
@ -102,11 +102,11 @@ class TileLayerTerrain(tileGroup: TileGroup, size: Float) : TileLayer(tileGroup,
|
|||
.flatMap { getMatchingEdges(tile, it) }
|
||||
}
|
||||
|
||||
private fun getMatchingEdges(originTile: Tile, neighborTile: Tile): List<String>{
|
||||
private fun getMatchingEdges(originTile: Tile, neighborTile: Tile): Sequence<String>{
|
||||
val vectorToNeighbor = neighborTile.position.cpy().sub(originTile.position)
|
||||
val direction = NeighborDirection.fromVector(vectorToNeighbor)
|
||||
?: return emptyList()
|
||||
val possibleEdgeFiles = strings().edgeImagesByPosition[direction] ?: return emptyList()
|
||||
?: return emptySequence()
|
||||
val possibleEdgeFiles = strings().edgeImagesByPosition[direction] ?: return emptySequence()
|
||||
|
||||
// Required for performance - full matchesFilter is too expensive for something that needs to run every update()
|
||||
fun matchesFilterMinimal(originTile: Tile, filter: String): Boolean {
|
||||
|
|
@ -115,7 +115,7 @@ class TileLayerTerrain(tileGroup: TileGroup, size: Float) : TileLayer(tileGroup,
|
|||
return false
|
||||
}
|
||||
|
||||
return possibleEdgeFiles.filter {
|
||||
return possibleEdgeFiles.asSequence().filter {
|
||||
if (!matchesFilterMinimal(originTile, it.originTileFilter)) return@filter false
|
||||
if (!matchesFilterMinimal(neighborTile, it.destinationTileFilter)) return@filter false
|
||||
return@filter true
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ class EditorMapHolder(
|
|||
|
||||
val tileGroups = HashMap<Tile, TileGroup>()
|
||||
private lateinit var tileGroupMap: TileGroupMap<TileGroup>
|
||||
private val allTileGroups = ArrayList<TileGroup>()
|
||||
private val allTileGroups = ArrayList<TileGroup>(tileMap.values.size)
|
||||
|
||||
private var blinkAction: Action? = null
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user