avoid unnecessary computation during entry cell sizing on table scrolls

This commit is contained in:
Craig Raw 2022-07-14 08:35:31 +02:00
parent 2d42ebff13
commit 4217de15a3

View file

@ -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) {