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:
Alex Vasile 2023-08-27 17:58:19 -04:00 committed by GitHub
parent 53be4f384e
commit a2162ec3e7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
65 changed files with 262 additions and 196 deletions

View file

@ -63,19 +63,19 @@ public class EquipAbility extends ActivatedAbilityImpl {
@Override
public String getRule() {
String targetText = getTargets().get(0) != null ? getTargets().get(0).getFilter().getMessage() : "creature";
String reminderText = " <i>(" + manaCosts.getText() + ": Attach to target " + targetText + ". Equip only as a sorcery.)</i>";
String reminderText = " <i>(" + getManaCosts().getText() + ": Attach to target " + targetText + ". Equip only as a sorcery.)</i>";
StringBuilder sb = new StringBuilder("Equip");
if (!targetText.equals("creature you control")) {
sb.append(' ').append(targetText);
}
String costText = costs.getText();
String costText = getCosts().getText();
if (costText != null && !costText.isEmpty()) {
sb.append("&mdash;").append(costText).append('.');
} else {
sb.append(' ');
}
sb.append(manaCosts.getText());
sb.append(getManaCosts().getText());
if (costReduceText != null && !costReduceText.isEmpty()) {
sb.append(". ");
sb.append(costReduceText);