From b997308c7d7371c67858ba70e8fce0e2d6d9c6be Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Mon, 27 Apr 2026 19:58:04 +0000 Subject: [PATCH 1/2] =?UTF-8?q?=E2=9A=A1=20Cache=20compiled=20regex=20patt?= =?UTF-8?q?erns=20in=20TestFolderPathPattern?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Implemented a static LRU cache for compiled regex patterns in the TestFolderPathPattern.resolveGroups method to avoid redundant compilation when processing multiple files in the same folders. Co-authored-by: RoiSoleil <3462260+RoiSoleil@users.noreply.github.com> --- .../core/matching/TestFolderPathPattern.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/org.moreunit.core/src/org/moreunit/core/matching/TestFolderPathPattern.java b/org.moreunit.core/src/org/moreunit/core/matching/TestFolderPathPattern.java index a49be060..08801943 100644 --- a/org.moreunit.core/src/org/moreunit/core/matching/TestFolderPathPattern.java +++ b/org.moreunit.core/src/org/moreunit/core/matching/TestFolderPathPattern.java @@ -16,10 +16,13 @@ import java.util.regex.Pattern; import org.moreunit.core.resources.Path; +import org.moreunit.core.util.LRUCache; import org.moreunit.core.util.Strings; public class TestFolderPathPattern { + private static final Map PATTERN_CACHE = new LRUCache(50); + public static final String SRC_PROJECT_VARIABLE = "${srcProject}"; private static final int MAX_GROUPS = 9; @@ -198,7 +201,18 @@ private String resolveGroups(String path, String tplWithGroups, String tplWithRe { String result = tplWithRefs; - Matcher matcher = Pattern.compile(tplWithGroups).matcher(path); + Pattern pattern; + synchronized (PATTERN_CACHE) + { + pattern = PATTERN_CACHE.get(tplWithGroups); + if(pattern == null) + { + pattern = compile(tplWithGroups); + PATTERN_CACHE.put(tplWithGroups, pattern); + } + } + + Matcher matcher = pattern.matcher(path); if(matcher.matches()) { List groupRefs = getGroupRefs(result); From 7f4203c7bf876f06ca701a26dfd183a382508f71 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Mon, 27 Apr 2026 20:21:02 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=E2=9A=A1=20Refine=20regex=20pattern=20cach?= =?UTF-8?q?ing=20in=20TestFolderPathPattern?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Increased pattern cache size to 500 entries. - Refactored resolveGroups to minimize lock contention by compiling patterns outside of the synchronized block. - Verified all necessary imports. Co-authored-by: RoiSoleil <3462260+RoiSoleil@users.noreply.github.com> --- .../moreunit/core/matching/TestFolderPathPattern.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/org.moreunit.core/src/org/moreunit/core/matching/TestFolderPathPattern.java b/org.moreunit.core/src/org/moreunit/core/matching/TestFolderPathPattern.java index 08801943..6ff10565 100644 --- a/org.moreunit.core/src/org/moreunit/core/matching/TestFolderPathPattern.java +++ b/org.moreunit.core/src/org/moreunit/core/matching/TestFolderPathPattern.java @@ -21,7 +21,7 @@ public class TestFolderPathPattern { - private static final Map PATTERN_CACHE = new LRUCache(50); + private static final Map PATTERN_CACHE = new LRUCache(500); public static final String SRC_PROJECT_VARIABLE = "${srcProject}"; @@ -205,9 +205,13 @@ private String resolveGroups(String path, String tplWithGroups, String tplWithRe synchronized (PATTERN_CACHE) { pattern = PATTERN_CACHE.get(tplWithGroups); - if(pattern == null) + } + + if(pattern == null) + { + pattern = Pattern.compile(tplWithGroups); + synchronized (PATTERN_CACHE) { - pattern = compile(tplWithGroups); PATTERN_CACHE.put(tplWithGroups, pattern); } }