From c22b8bab03e33b68204e57d09613be0caeab3993 Mon Sep 17 00:00:00 2001 From: Nico Piel Date: Wed, 27 May 2026 22:46:57 +0200 Subject: [PATCH] Eliminate O(n^2) status removal in DashboardTreeTableModel MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updateChannelNodes called statuses.remove(status) inside a loop over child nodes. With an ArrayList, each remove is O(n), making the update O(channels × statuses). Collected matched statuses in a HashSet and called removeAll once after the loop, reducing to O(n + m). Signed-off-by: Nico Piel --- .../com/mirth/connect/client/ui/DashboardTreeTableModel.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/client/src/com/mirth/connect/client/ui/DashboardTreeTableModel.java b/client/src/com/mirth/connect/client/ui/DashboardTreeTableModel.java index a30361d960..3f1471cbed 100644 --- a/client/src/com/mirth/connect/client/ui/DashboardTreeTableModel.java +++ b/client/src/com/mirth/connect/client/ui/DashboardTreeTableModel.java @@ -498,13 +498,14 @@ private void updateChannelNodes(List statuses, MutableTreeTable } private void updateChannelNodes(Map statusMap, List statuses, MutableTreeTableNode parent) { + Set matched = new HashSet<>(); for (int i = 0; i < parent.getChildCount(); i++) { AbstractDashboardTableNode node = (AbstractDashboardTableNode) parent.getChildAt(i); if (statusMap.containsKey(node.getDashboardStatus().getKey())) { // Remove channels that do exist from the list of statuses so they will not be added again later. DashboardStatus status = statusMap.get(node.getDashboardStatus().getKey()); - statuses.remove(status); + matched.add(status); // Update the channel status node.setDashboardStatus(status); modelSupport.firePathChanged(new TreePath(getPathToRoot(node))); @@ -513,6 +514,7 @@ private void updateChannelNodes(Map statusMap, List statuses, MutableTreeTableNode root) {