mirror of
https://github.com/yairm210/Unciv.git
synced 2024-12-22 23:24:25 +07:00
perf(memory): Reuse conditional states
This commit is contained in:
parent
b1a3a4d89d
commit
6751739f39
@ -78,9 +78,9 @@ class TileStatFunctions(val tile: Tile) {
|
||||
val tileType = unique.params[1]
|
||||
if (tile.matchesFilter(tileType, observingCiv, true))
|
||||
listOfStats.add("{${unique.sourceObjectName}} ({${unique.getDisplayText()}})" to unique.stats)
|
||||
else if (improvement != null && improvement.matchesFilter(tileType, StateForConditionals(city = city, tile = tile)))
|
||||
else if (improvement != null && improvement.matchesFilter(tileType, stateForConditionals))
|
||||
improvementStats.add(unique.stats)
|
||||
else if (road != null && road.matchesFilter(tileType, StateForConditionals(city = city, tile = tile)))
|
||||
else if (road != null && road.matchesFilter(tileType, stateForConditionals))
|
||||
roadStats.add(unique.stats)
|
||||
}
|
||||
}
|
||||
@ -133,7 +133,7 @@ class TileStatFunctions(val tile: Tile) {
|
||||
private fun missingFromMinimum(current: Stats, minimumStats: Stats): Stats {
|
||||
// Note: Not `for ((stat, value) in other)` - that would skip zero values
|
||||
val missingStats = Stats()
|
||||
for (stat in Stat.values()) {
|
||||
for (stat in Stat.entries) {
|
||||
if (current[stat] < minimumStats[stat])
|
||||
missingStats[stat] = minimumStats[stat] - current[stat]
|
||||
}
|
||||
@ -203,7 +203,7 @@ class TileStatFunctions(val tile: Tile) {
|
||||
val cachedAllStatPercentFromObjectCityUniques = uniqueCache.forCityGetMatchingUniques(
|
||||
city, UniqueType.AllStatsPercentFromObject, stateForConditionals)
|
||||
for (unique in cachedAllStatPercentFromObjectCityUniques) {
|
||||
for (stat in Stat.values())
|
||||
for (stat in Stat.entries)
|
||||
addStats(unique.params[1], stat, unique.params[0].toFloat())
|
||||
}
|
||||
|
||||
@ -217,7 +217,7 @@ class TileStatFunctions(val tile: Tile) {
|
||||
val cachedAllStatPercentFromObjectCivUniques = uniqueCache.forCivGetMatchingUniques(
|
||||
observingCiv, UniqueType.AllStatsPercentFromObject, stateForConditionals)
|
||||
for (unique in cachedAllStatPercentFromObjectCivUniques) {
|
||||
for (stat in Stat.values())
|
||||
for (stat in Stat.entries)
|
||||
addStats(unique.params[1], stat, unique.params[0].toFloat())
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user