From 91dde14306f2b296f580377a76489695570c4685 Mon Sep 17 00:00:00 2001 From: Nico Piel Date: Wed, 27 May 2026 22:46:03 +0200 Subject: [PATCH 1/2] Cache compiled regex Pattern in MirthTree Pattern.compile(" (\\(.*\\))") was called on every iteration of two tree-traversal while-loops in constructVariableName and constructNodeDescription. Pattern compilation is expensive and the pattern never changes. Extracted to a static final field. Signed-off-by: Nico Piel --- .../com/mirth/connect/client/ui/components/MirthTree.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/client/src/com/mirth/connect/client/ui/components/MirthTree.java b/client/src/com/mirth/connect/client/ui/components/MirthTree.java index 300262439a..cc424ed301 100644 --- a/client/src/com/mirth/connect/client/ui/components/MirthTree.java +++ b/client/src/com/mirth/connect/client/ui/components/MirthTree.java @@ -46,6 +46,8 @@ public class MirthTree extends JXTree implements DropTargetListener { + private static final Pattern PAREN_PATTERN = Pattern.compile(" (\\(.*\\))"); + private Frame parent; private MyFilter mf; private FilterTreeModel ftm; @@ -502,8 +504,7 @@ public static String constructVariable(TreeNode parent) { // because we don't want to include the root node. while (node != null && node.getParent() != null) { String parentName = node.getValue(); - Pattern pattern = Pattern.compile(" (\\(.*\\))"); - Matcher matcher = pattern.matcher(parentName.toString()); + Matcher matcher = PAREN_PATTERN.matcher(parentName.toString()); if (serializationType.equals(SerializationType.JSON) && node.isArrayElement()) { if (variable.length() != 0) { @@ -566,8 +567,7 @@ public static String constructNodeDescription(TreeNode parent) { // because we don't want to include the root node. while (node != null && node.getParent() != null) { String parentName = node.getValue(); - Pattern pattern = Pattern.compile(" (\\(.*\\))"); - Matcher matcher = pattern.matcher(parentName.toString()); + Matcher matcher = PAREN_PATTERN.matcher(parentName.toString()); // Get the index of the parent about to be added. String parentIndex = ""; From 4c04f6915eda9804fd2e7a608d0b671ee05e6f16 Mon Sep 17 00:00:00 2001 From: Nico Piel Date: Wed, 27 May 2026 23:00:32 +0200 Subject: [PATCH 2/2] Fixed typo Signed-off-by: Nico Piel --- .../com/mirth/connect/client/ui/components/MirthTree.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client/src/com/mirth/connect/client/ui/components/MirthTree.java b/client/src/com/mirth/connect/client/ui/components/MirthTree.java index cc424ed301..33211c88d3 100644 --- a/client/src/com/mirth/connect/client/ui/components/MirthTree.java +++ b/client/src/com/mirth/connect/client/ui/components/MirthTree.java @@ -46,7 +46,7 @@ public class MirthTree extends JXTree implements DropTargetListener { - private static final Pattern PAREN_PATTERN = Pattern.compile(" (\\(.*\\))"); + private static final Pattern PARENT_PATTERN = Pattern.compile(" (\\(.*\\))"); private Frame parent; private MyFilter mf; @@ -504,7 +504,7 @@ public static String constructVariable(TreeNode parent) { // because we don't want to include the root node. while (node != null && node.getParent() != null) { String parentName = node.getValue(); - Matcher matcher = PAREN_PATTERN.matcher(parentName.toString()); + Matcher matcher = PARENT_PATTERN.matcher(parentName.toString()); if (serializationType.equals(SerializationType.JSON) && node.isArrayElement()) { if (variable.length() != 0) { @@ -567,7 +567,7 @@ public static String constructNodeDescription(TreeNode parent) { // because we don't want to include the root node. while (node != null && node.getParent() != null) { String parentName = node.getValue(); - Matcher matcher = PAREN_PATTERN.matcher(parentName.toString()); + Matcher matcher = PARENT_PATTERN.matcher(parentName.toString()); // Get the index of the parent about to be added. String parentIndex = "";