mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 04:08:01 +00:00
CardDb: dont keep allCards list just use values collection
This commit is contained in:
@@ -50,8 +50,7 @@ public final class CardDb implements ICardDatabase, IDeckGenPool {
|
||||
private final Map<String, String> alternateName = Maps.newTreeMap(String.CASE_INSENSITIVE_ORDER);
|
||||
private final Map<String, Integer> artIds = new HashMap<>();
|
||||
|
||||
private final List<PaperCard> allCards = new ArrayList<>();
|
||||
private final List<PaperCard> roAllCards = Collections.unmodifiableList(allCards);
|
||||
private final Collection<PaperCard> roAllCards = Collections.unmodifiableCollection(allCardsByName.values());
|
||||
private final CardEdition.Collection editions;
|
||||
|
||||
public enum SetPreference {
|
||||
@@ -247,10 +246,8 @@ public final class CardDb implements ICardDatabase, IDeckGenPool {
|
||||
|
||||
private void reIndex() {
|
||||
uniqueCardsByName.clear();
|
||||
allCards.clear();
|
||||
for (Entry<String, Collection<PaperCard>> kv : allCardsByName.asMap().entrySet()) {
|
||||
uniqueCardsByName.put(kv.getKey(), getFirstWithImage(kv.getValue()));
|
||||
allCards.addAll(kv.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -537,7 +534,7 @@ public final class CardDb implements ICardDatabase, IDeckGenPool {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PaperCard> getAllCards() {
|
||||
public Collection<PaperCard> getAllCards() {
|
||||
return roAllCards;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,9 +24,9 @@ public interface ICardDatabase extends Iterable<PaperCard> {
|
||||
int getArtCount(String cardName, String edition);
|
||||
|
||||
Collection<PaperCard> getUniqueCards();
|
||||
List<PaperCard> getAllCards();
|
||||
List<PaperCard> getAllCards(String cardName);
|
||||
List<PaperCard> getAllCards(Predicate<PaperCard> predicate);
|
||||
Collection<PaperCard> getAllCards();
|
||||
Collection<PaperCard> getAllCards(String cardName);
|
||||
Collection<PaperCard> getAllCards(Predicate<PaperCard> predicate);
|
||||
|
||||
List<PaperCard> getAllCardsFromEdition(CardEdition edition);
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ import forge.util.storage.StorageReaderFile;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@@ -102,7 +103,7 @@ public class QuestWorld implements Comparable<QuestWorld>{
|
||||
return format;
|
||||
}
|
||||
|
||||
public List<PaperCard> getAllCards() {
|
||||
public Collection<PaperCard> getAllCards() {
|
||||
GameFormat format0 = format;
|
||||
if (format0 == null) {
|
||||
format0 = FModel.getQuest().getMainFormat();
|
||||
|
||||
Reference in New Issue
Block a user