mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 21:12:04 -08:00
performance: improved CPU usage in games with big amount of permanents (related to #11285)
This commit is contained in:
parent
1f50f95f8b
commit
70c79fd6a6
4 changed files with 14 additions and 5 deletions
|
|
@ -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());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@ import mage.abilities.Ability;
|
|||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.target.targetpointer.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
|
@ -16,13 +16,16 @@ import java.util.stream.Collectors;
|
|||
*/
|
||||
public class Targets extends ArrayList<Target> {
|
||||
|
||||
public Targets() {
|
||||
// fast constructor
|
||||
}
|
||||
|
||||
public Targets(Target... targets) {
|
||||
for (Target target : targets) {
|
||||
this.add(target);
|
||||
}
|
||||
this.addAll(Arrays.asList(targets));
|
||||
}
|
||||
|
||||
protected Targets(final Targets targets) {
|
||||
this.ensureCapacity(targets.size());
|
||||
for (Target target : targets) {
|
||||
this.add(target.copy());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue