Browse Source

avoid unnecessary computation during entry cell sizing on table scrolls

terminal
Craig Raw 2 years ago
parent
commit
4217de15a3
  1. 8
      src/main/java/com/sparrowwallet/sparrow/control/EntryCell.java

8
src/main/java/com/sparrowwallet/sparrow/control/EntryCell.java

@ -36,6 +36,8 @@ public class EntryCell extends TreeTableCell<Entry, Entry> {
public static final DateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm"); public static final DateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm");
private static final Pattern REPLACED_BY_FEE_SUFFIX = Pattern.compile("(.*)\\(Replaced By Fee( #)?(\\d+)?\\).*"); private static final Pattern REPLACED_BY_FEE_SUFFIX = Pattern.compile("(.*)\\(Replaced By Fee( #)?(\\d+)?\\).*");
private static EntryCell lastCell;
public EntryCell() { public EntryCell() {
super(); super();
setAlignment(Pos.CENTER_LEFT); setAlignment(Pos.CENTER_LEFT);
@ -47,6 +49,12 @@ public class EntryCell extends TreeTableCell<Entry, Entry> {
protected void updateItem(Entry entry, boolean empty) { protected void updateItem(Entry entry, boolean empty) {
super.updateItem(entry, empty); super.updateItem(entry, empty);
//Return immediately to avoid CPU usage when updating the same invisible cell to determine tableview size (see https://bugs.openjdk.org/browse/JDK-8280442)
if(this == lastCell && !getTableRow().isVisible()) {
return;
}
lastCell = this;
applyRowStyles(this, entry); applyRowStyles(this, entry);
if(empty) { if(empty) {

Loading…
Cancel
Save