forked from External/mage
Refactor: private fields and performance tweaks (#9625)
1a. Make `costs`, `manaCosts`, and `manaCostsToPay` private in `AbilityImpl` with access through getters/setters 1b. fix cost adjuster for imprinted cards affected by the above 2a. Lazy instantiation for rarely used `data` field in `TargetPointerImpl` 3a. Pre-allocate certain array sizes in `Modes` and `CostsImpl` 4a. Make `manaTemplate` private in `BasicManaEffect`, copy when passing outside the class 4b. Don't copy `manaTemplate` in copy constructor since it doesn't change 4c. Add comments explaining copy usage for `manaTemplate` 4d. Remove redundant variable assignment and make fields final --------- Co-authored-by: xenohedron <xenohedron@users.noreply.github.com>
This commit is contained in:
parent
53be4f384e
commit
a2162ec3e7
65 changed files with 262 additions and 196 deletions
|
|
@ -141,8 +141,8 @@ public final class CardUtil {
|
|||
*/
|
||||
private static void adjustAbilityCost(Ability ability, int reduceCount) {
|
||||
ManaCosts<ManaCost> adjustedCost = adjustCost(ability.getManaCostsToPay(), reduceCount);
|
||||
ability.getManaCostsToPay().clear();
|
||||
ability.getManaCostsToPay().addAll(adjustedCost);
|
||||
ability.clearManaCostsToPay();
|
||||
ability.addManaCostsToPay(adjustedCost);
|
||||
}
|
||||
|
||||
private static ManaCosts<ManaCost> adjustCost(ManaCosts<ManaCost> manaCosts, int reduceCount) {
|
||||
|
|
@ -304,8 +304,8 @@ public final class CardUtil {
|
|||
increasedCost.add(manaCost.copy());
|
||||
}
|
||||
|
||||
spellAbility.getManaCostsToPay().clear();
|
||||
spellAbility.getManaCostsToPay().addAll(increasedCost);
|
||||
spellAbility.clearManaCostsToPay();
|
||||
spellAbility.addManaCostsToPay(increasedCost);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -468,8 +468,8 @@ public final class CardUtil {
|
|||
adjustedCost.add(new GenericManaCost(0)); // neede to check if cost was reduced to 0
|
||||
}
|
||||
adjustedCost.setSourceFilter(previousCost.getSourceFilter()); // keep mana source restrictions
|
||||
spellAbility.getManaCostsToPay().clear();
|
||||
spellAbility.getManaCostsToPay().addAll(adjustedCost);
|
||||
spellAbility.clearManaCostsToPay();
|
||||
spellAbility.addManaCostsToPay(adjustedCost);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue