mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
Still scratching a little of performance impros by avoiding checking class instance.
When StatTypeFilter is used withing Deck Editor (with all PaperCard instance in ItemPool), avoiding checking instance class improves performance a bit (saving a couple of hundreds of milliseconds). However, when this filter with also other inventory items (pack or deck), the same code as before is executed.
This commit is contained in:
@@ -75,14 +75,23 @@ public abstract class StatTypeFilter<T extends InventoryItem> extends ToggleButt
|
||||
if (btnPackOrDeck != null) { //support special pack/deck case
|
||||
int count = items.countAll(ItemPredicate.Presets.IS_PACK_OR_DECK, InventoryItem.class);
|
||||
btnPackOrDeck.setText(String.valueOf(count));
|
||||
}
|
||||
|
||||
Iterator<StatTypes> buttonMapStatsIterator = buttonMap.keySet().iterator();
|
||||
while (buttonMapStatsIterator.hasNext()){
|
||||
StatTypes statTypes = buttonMapStatsIterator.next();
|
||||
if (statTypes.predicate != null){
|
||||
int count = items.countAll(Predicates.compose(statTypes.predicate, PaperCard.FN_GET_RULES), PaperCard.class);
|
||||
buttonMap.get(statTypes).setText(String.valueOf(count));
|
||||
Iterator<StatTypes> buttonMapStatsIterator = buttonMap.keySet().iterator();
|
||||
while (buttonMapStatsIterator.hasNext()){
|
||||
StatTypes statTypes = buttonMapStatsIterator.next();
|
||||
if (statTypes.predicate != null){
|
||||
count = items.countAll(Predicates.compose(statTypes.predicate, PaperCard.FN_GET_RULES), PaperCard.class);
|
||||
buttonMap.get(statTypes).setText(String.valueOf(count));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Iterator<StatTypes> buttonMapStatsIterator = buttonMap.keySet().iterator();
|
||||
while (buttonMapStatsIterator.hasNext()) {
|
||||
StatTypes statTypes = buttonMapStatsIterator.next();
|
||||
if (statTypes.predicate != null) {
|
||||
int count = items.countAll(Predicates.compose(statTypes.predicate, PaperCard.FN_GET_RULES));
|
||||
buttonMap.get(statTypes).setText(String.valueOf(count));
|
||||
}
|
||||
}
|
||||
}
|
||||
getWidget().revalidate();
|
||||
|
||||
Reference in New Issue
Block a user