Performance improvements

- unit unique check uses map, not array search
This commit is contained in:
Yair Morgenstern 2023-06-18 00:25:03 +03:00
parent e634423b2f
commit ead83b912b
2 changed files with 3 additions and 4 deletions

View File

@ -311,7 +311,7 @@ class BaseUnit : RulesetObject(), INonPerpetualConstruction {
// "military units" --> "Military", using invariant locale
&& matchesFilter(filter.removeSuffix(" units").lowercase().replaceFirstChar { it.uppercaseChar() })
) return true
return uniques.contains(filter)
return uniqueMap.contains(filter)
}
}
}

View File

@ -42,9 +42,8 @@ class UnitType() : RulesetObject() {
"Land" -> isLandUnit()
"Water" -> isWaterUnit()
"Air" -> isAirUnit()
else -> {
uniques.contains(filter)
}
in uniqueMap -> true
else -> false
}
}