Perf Impro to Deck Editor Loading Issue #1847

This is another extra improvement which avoids setting up card catalog in current editor whenever it is actually **not** needed.

To do so, ItemPool now implements and equal method, which reflects to equality of contained items.
This is because card pool is set up multiple times whenever the Deck Editor tab is initialised - and the operation of setting up the catalog manager is particularly expensive (let alone useless when it's already done!)

Signed-off-by: leriomaggio <valeriomaggio@gmail.com>
This commit is contained in:
leriomaggio
2021-09-07 11:46:44 +01:00
parent 7c1bcaaf34
commit 20d9dbdb57
2 changed files with 9 additions and 1 deletions

View File

@@ -273,4 +273,10 @@ public class ItemPool<T extends InventoryItem> implements Iterable<Entry<T, Inte
public void clear() {
items.clear();
}
@Override
public boolean equals(final Object obj) {
return (obj instanceof ItemPool) &&
(this.items.equals(((ItemPool)obj).items));
}
}

View File

@@ -396,6 +396,8 @@ public final class CEditorConstructed extends CDeckEditor<Deck> {
public void resetTables() {
// Constructed mode can use all cards, no limitations.
this.sectionMode = DeckSection.Main;
ItemPool currentPool = this.getCatalogManager().getPool();
if (currentPool == null || !currentPool.equals(normalPool))
this.getCatalogManager().setPool(normalPool, true);
this.getDeckManager().setPool(this.controller.getModel().getMain());
}