performance: improved CPU usage in games with big amount of permanents (related to #11285)

This commit is contained in:
Oleg Agafonov 2023-11-07 01:14:07 +04:00
parent 1f50f95f8b
commit 70c79fd6a6
4 changed files with 14 additions and 5 deletions

View file

@ -24,11 +24,16 @@ public class AbilitiesImpl<T extends Ability> extends ArrayList<T> implements Ab
private static final ThreadLocalStringBuilder threadLocalBuilder = new ThreadLocalStringBuilder(200);
public AbilitiesImpl() {
// fast constructor
}
public AbilitiesImpl(T... abilities) {
Collections.addAll(this, abilities);
}
public AbilitiesImpl(final AbilitiesImpl<T> abilities) {
this.ensureCapacity(abilities.size());
for (T ability : abilities) {
this.add((T) ability.copy());
}

View file

@ -12,7 +12,7 @@ public abstract class CostImpl implements Cost {
protected UUID id;
protected String text;
protected boolean paid;
protected Targets targets;
protected Targets targets; // TODO: optimize performance - use private and null by default
public CostImpl() {
id = UUID.randomUUID();

View file

@ -45,6 +45,7 @@ public class ManaCostsImpl<T extends ManaCost> extends ArrayList<T> implements M
private ManaCostsImpl(final ManaCostsImpl<T> costs) {
this.id = costs.id;
this.text = costs.text;
this.ensureCapacity(costs.size());
for (T cost : costs) {
this.add(cost.copy());
}