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:
leriomaggio
2021-08-28 16:47:10 +01:00
parent 42e91b60ea
commit 7613b27e6e
2 changed files with 24 additions and 12 deletions

View File

@@ -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();