mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-06 16:28:40 +07:00
Use empty lists and maps for objects with no uniques for less memory consumption
This commit is contained in:
@ -13,11 +13,13 @@ abstract class RulesetObject: IRulesetObject {
|
||||
override var uniques = ArrayList<String>() // Can not be a hashset as that would remove doubles
|
||||
@delegate:Transient
|
||||
override val uniqueObjects: List<Unique> by lazy {
|
||||
uniques.map { Unique(it, getUniqueTarget(), name) }
|
||||
if (uniques.isEmpty()) emptyList()
|
||||
else uniques.map { Unique(it, getUniqueTarget(), name) }
|
||||
}
|
||||
@delegate:Transient
|
||||
override val uniqueMap: Map<String, List<Unique>> by lazy {
|
||||
uniqueObjects.groupBy { it.placeholderText }
|
||||
if (uniques.isEmpty()) emptyMap()
|
||||
else uniqueObjects.groupBy { it.placeholderText }
|
||||
}
|
||||
override var civilopediaText = listOf<FormattedLine>()
|
||||
override fun toString() = name
|
||||
@ -28,11 +30,13 @@ abstract class RulesetStatsObject: NamedStats(), IRulesetObject {
|
||||
override var uniques = ArrayList<String>() // Can not be a hashset as that would remove doubles
|
||||
@delegate:Transient
|
||||
override val uniqueObjects: List<Unique> by lazy {
|
||||
uniques.map { Unique(it, getUniqueTarget(), name) }
|
||||
if (uniques.isEmpty()) emptyList()
|
||||
else uniques.map { Unique(it, getUniqueTarget(), name) }
|
||||
}
|
||||
@delegate:Transient
|
||||
override val uniqueMap: Map<String, List<Unique>> by lazy {
|
||||
uniqueObjects.groupBy { it.placeholderText }
|
||||
if (uniques.isEmpty()) emptyMap()
|
||||
else uniqueObjects.groupBy { it.placeholderText }
|
||||
}
|
||||
override var civilopediaText = listOf<FormattedLine>()
|
||||
}
|
||||
|
Reference in New Issue
Block a user