mirror of
https://github.com/magefree/mage.git
synced 2026-01-26 13:19:18 -08:00
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
|
|
@ -0,0 +1,32 @@
|
|||
package org.mage.test.performance;
|
||||
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Zone;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||
|
||||
/**
|
||||
* These tests are used to benchmark the performance of the copying of the state.
|
||||
* <p>
|
||||
* Leave the tests comment out when pushing, uncomment only when testing locally.
|
||||
*
|
||||
* @author Alex-Vasile
|
||||
*/
|
||||
public class StateCopying extends CardTestPlayerBase {
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void copyingBattlefield() {
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 10);
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Sol Ring", 10);
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Sapphire Medallion", 10);
|
||||
|
||||
setStopAt(1, PhaseStep.END_TURN);
|
||||
execute();
|
||||
|
||||
for (int i = 0; i < 100000; i++) {
|
||||
currentGame.getBattlefield().reset(currentGame);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue