From 4217de15a344b86bff9f383775fb2d88ede9b40a Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Thu, 14 Jul 2022 08:35:31 +0200 Subject: [PATCH] avoid unnecessary computation during entry cell sizing on table scrolls --- .../java/com/sparrowwallet/sparrow/control/EntryCell.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/com/sparrowwallet/sparrow/control/EntryCell.java b/src/main/java/com/sparrowwallet/sparrow/control/EntryCell.java index ad411042..49597b1f 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/EntryCell.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/EntryCell.java @@ -36,6 +36,8 @@ public class EntryCell extends TreeTableCell { 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 EntryCell lastCell; + public EntryCell() { super(); setAlignment(Pos.CENTER_LEFT); @@ -47,6 +49,12 @@ public class EntryCell extends TreeTableCell { protected void updateItem(Entry entry, boolean 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); if(empty) {