From 2d8e4e90530abde0962d7159d376c3b18d63cbf1 Mon Sep 17 00:00:00 2001 From: Maxmtg Date: Thu, 3 Oct 2013 08:06:10 +0000 Subject: [PATCH] removed some (not all) slowdonws in quest card shop when owner of a big collection purchases a fatpack. (there were N redraws of owned card list instead of just one) --- .../controllers/CEditorQuestCardShop.java | 13 +++++----- .../gui/toolbox/itemmanager/ItemManager.java | 26 +++---------------- 2 files changed, 9 insertions(+), 30 deletions(-) diff --git a/src/main/java/forge/gui/deckeditor/controllers/CEditorQuestCardShop.java b/src/main/java/forge/gui/deckeditor/controllers/CEditorQuestCardShop.java index 12d5f302eb2..04357136d85 100644 --- a/src/main/java/forge/gui/deckeditor/controllers/CEditorQuestCardShop.java +++ b/src/main/java/forge/gui/deckeditor/controllers/CEditorQuestCardShop.java @@ -364,7 +364,6 @@ public final class CEditorQuestCardShop extends ACEditorBase newCards = booster.getCards(); - final List newInventory = new LinkedList(newCards); + + ItemPool newInventory = new ItemPool(InventoryItem.class); + newInventory.addAllFlat(newCards); getDeckManager().addItems(newInventory); - final CardListViewer c = new CardListViewer(booster.getName(), - "You have found the following cards inside:", newCards); + final CardListViewer c = new CardListViewer(booster.getName(), "You have found the following cards inside:", newCards); c.show(); } - this.getCatalogManager().removeItem(item, qty); } else if (item instanceof PreconDeck) { final PreconDeck deck = (PreconDeck) item; this.questData.getCards().buyPreconDeck(deck, value); @@ -400,8 +399,8 @@ public final class CEditorQuestCardShop extends ACEditorBase extends JPanel { */ public void addItems(Iterable> itemsToAdd) { final int n = this.table.getSelectedRow(); - for (Map.Entry item : itemsToAdd) { - this.pool.add(item.getKey(), item.getValue()); - if (this.isUnfiltered()) { - this.model.addItem(item.getKey(), item.getValue()); - } - } - this.updateView(false); - this.table.fixSelection(n); - } - - /** - * - * addItems. - * - * @param itemsToAdd - */ - public void addItems(Collection itemsToAdd) { - final int n = this.table.getSelectedRow(); - for (T item : itemsToAdd) { - this.pool.add(item, 1); - if (this.isUnfiltered()) { - this.model.addItem(item, 1); - } + this.pool.addAll(itemsToAdd); + if (this.isUnfiltered()) { + this.model.addItems(itemsToAdd); } this.updateView(false); this.table.fixSelection(n);