mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-09 23:39:40 +07:00
perf: sequenceOf() -> emptySequence()
This commit is contained in:
@ -95,7 +95,7 @@ object AndroidImagePacker {
|
||||
fun File.listTree(): Sequence<File> = when {
|
||||
this.isFile -> sequenceOf(this)
|
||||
this.isDirectory -> this.listFiles()!!.asSequence().flatMap { it.listTree() }
|
||||
else -> sequenceOf()
|
||||
else -> emptySequence()
|
||||
}
|
||||
|
||||
// Check if outdated
|
||||
|
@ -373,7 +373,8 @@ class WorkerAutomation(
|
||||
return ruleSet.tileImprovements[improvementString] // For mods, the tile improvement may not exist, so don't assume.
|
||||
}
|
||||
|
||||
private fun getImprovementRanking(tile: Tile, unit: MapUnit, improvementName: String, localUniqueCache: LocalUniqueCache): Float {
|
||||
private fun getImprovementRanking(tile: Tile, unit: MapUnit, improvementName: String,
|
||||
localUniqueCache: LocalUniqueCache): Float {
|
||||
val improvement = ruleSet.tileImprovements[improvementName]!!
|
||||
|
||||
// Add the value of roads if we want to build it here
|
||||
|
@ -266,7 +266,7 @@ class CityStats(val city: City) {
|
||||
city.getMatchingUniques(UniqueType.PercentProductionWonders)
|
||||
currentConstruction is Building && !currentConstruction.isAnyWonder() ->
|
||||
city.getMatchingUniques(UniqueType.PercentProductionBuildings)
|
||||
else -> sequenceOf() // Science/Gold production
|
||||
else -> emptySequence() // Science/Gold production
|
||||
}
|
||||
|
||||
for (unique in uniquesToCheck) {
|
||||
|
@ -58,7 +58,7 @@ class CityReligionManager : IsPartOfGameInfoSerialization {
|
||||
}
|
||||
|
||||
fun getUniques(uniqueType: UniqueType): Sequence<Unique> {
|
||||
val majorityReligion = getMajorityReligion() ?: return sequenceOf()
|
||||
val majorityReligion = getMajorityReligion() ?: return emptySequence()
|
||||
return majorityReligion.followerBeliefUniqueMap.getUniques(uniqueType)
|
||||
}
|
||||
|
||||
|
@ -147,7 +147,7 @@ class Tile : IsPartOfGameInfoSerialization, Json.Serializable {
|
||||
|
||||
@Transient
|
||||
/** Saves a sequence of a list */
|
||||
var allTerrains: Sequence<Terrain> = sequenceOf()
|
||||
var allTerrains: Sequence<Terrain> = emptySequence()
|
||||
private set
|
||||
|
||||
@Transient
|
||||
@ -473,7 +473,7 @@ class Tile : IsPartOfGameInfoSerialization, Json.Serializable {
|
||||
private fun matchesSingleTerrainFilter(filter: String, observingCiv: Civilization? = null): Boolean {
|
||||
return when (filter) {
|
||||
"Terrain" -> true
|
||||
in Constants.all -> true
|
||||
"All", "all" -> true
|
||||
baseTerrain -> true
|
||||
"Water" -> isWater
|
||||
"Land" -> isLand
|
||||
|
@ -387,12 +387,12 @@ class Spy private constructor() : IsPartOfGameInfoSerialization {
|
||||
city == null -> {
|
||||
// Spy is in hideout - effectiveness won't matter
|
||||
friendlyUniques = civInfo.getMatchingUniques(UniqueType.SpyEffectiveness)
|
||||
enemyUniques = sequenceOf()
|
||||
enemyUniques = emptySequence()
|
||||
}
|
||||
city.civ == civInfo -> {
|
||||
// Spy is in our own city
|
||||
friendlyUniques = city.getMatchingUniques(UniqueType.SpyEffectiveness, StateForConditionals(city), includeCivUniques = true)
|
||||
enemyUniques = sequenceOf()
|
||||
enemyUniques = emptySequence()
|
||||
}
|
||||
else -> {
|
||||
// Spy is active in a foreign city
|
||||
|
@ -34,7 +34,7 @@ interface INonPerpetualConstruction : IConstruction, INamed, IHasUniques {
|
||||
// https://yairm210.github.io/Unciv/Developers/Translations%2C-mods%2C-and-modding-freedom-in-Open-Source#filters
|
||||
var requiredTech: String?
|
||||
|
||||
override fun legacyRequiredTechs(): Sequence<String> = if (requiredTech == null) sequenceOf() else sequenceOf(requiredTech!!)
|
||||
override fun legacyRequiredTechs(): Sequence<String> = if (requiredTech == null) emptySequence() else sequenceOf(requiredTech!!)
|
||||
|
||||
fun getProductionCost(civInfo: Civilization, city: City?): Int
|
||||
fun getStatBuyCost(city: City, stat: Stat): Int?
|
||||
|
@ -36,7 +36,7 @@ interface IHasUniques : INamed {
|
||||
fun getUniqueTarget(): UniqueTarget
|
||||
|
||||
fun getMatchingUniques(uniqueTemplate: String, stateForConditionals: StateForConditionals? = null): Sequence<Unique> {
|
||||
val matchingUniques = uniqueMap[uniqueTemplate] ?: return sequenceOf()
|
||||
val matchingUniques = uniqueMap[uniqueTemplate] ?: return emptySequence()
|
||||
|
||||
val actualStateForConditionals = stateForConditionals ?: StateForConditionals()
|
||||
val uniques = matchingUniques.asSequence().filter { it.conditionalsApply(actualStateForConditionals) }
|
||||
@ -63,7 +63,7 @@ interface IHasUniques : INamed {
|
||||
.map { it.params[0] }
|
||||
}
|
||||
|
||||
fun legacyRequiredTechs(): Sequence<String> = sequenceOf()
|
||||
fun legacyRequiredTechs(): Sequence<String> = emptySequence()
|
||||
|
||||
fun requiredTechs(): Sequence<String> = legacyRequiredTechs() + techsRequiredByUniques()
|
||||
|
||||
|
@ -51,7 +51,7 @@ class BaseUnit : RulesetObject(), INonPerpetualConstruction {
|
||||
var replacementTextForUniques = ""
|
||||
var promotions = HashSet<String>()
|
||||
var obsoleteTech: String? = null
|
||||
fun techsThatObsoleteThis(): Sequence<String> = if (obsoleteTech == null) sequenceOf() else sequenceOf(obsoleteTech!!)
|
||||
fun techsThatObsoleteThis(): Sequence<String> = if (obsoleteTech == null) emptySequence() else sequenceOf(obsoleteTech!!)
|
||||
fun techsAtWhichAutoUpgradeInProduction(): Sequence<String> = techsThatObsoleteThis()
|
||||
fun techsAtWhichNoLongerAvailable(): Sequence<String> = techsThatObsoleteThis()
|
||||
@Suppress("unused") // Keep the how-to around
|
||||
|
@ -125,7 +125,7 @@ internal object ImagePacker {
|
||||
fun File.listTree(): Sequence<File> = when {
|
||||
this.isFile -> sequenceOf(this)
|
||||
this.isDirectory -> this.listFiles()!!.asSequence().flatMap { it.listTree() }
|
||||
else -> sequenceOf()
|
||||
else -> emptySequence()
|
||||
}
|
||||
|
||||
// Check if outdated
|
||||
|
Reference in New Issue
Block a user