Skip to content

Commit 1bdddf2

Browse files
⚡ Refine regex pattern caching in TestFolderPathPattern
- 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>
1 parent b8f40f3 commit 1bdddf2

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

org.moreunit.core/src/org/moreunit/core/matching/TestFolderPathPattern.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
public class TestFolderPathPattern
2323
{
24-
private static final Map<String, Pattern> PATTERN_CACHE = new LRUCache<String, Pattern>(50);
24+
private static final Map<String, Pattern> PATTERN_CACHE = new LRUCache<String, Pattern>(500);
2525

2626
public static final String SRC_PROJECT_VARIABLE = "${srcProject}";
2727

@@ -207,9 +207,13 @@ private String resolveGroups(String path, String tplWithGroups, String tplWithRe
207207
synchronized (PATTERN_CACHE)
208208
{
209209
pattern = PATTERN_CACHE.get(tplWithGroups);
210-
if(pattern == null)
210+
}
211+
212+
if(pattern == null)
213+
{
214+
pattern = Pattern.compile(tplWithGroups);
215+
synchronized (PATTERN_CACHE)
211216
{
212-
pattern = compile(tplWithGroups);
213217
PATTERN_CACHE.put(tplWithGroups, pattern);
214218
}
215219
}

0 commit comments

Comments
 (0)