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..6ff10565 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(500); + public static final String SRC_PROJECT_VARIABLE = "${srcProject}"; private static final int MAX_GROUPS = 9; @@ -198,7 +201,22 @@ 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 = Pattern.compile(tplWithGroups); + synchronized (PATTERN_CACHE) + { + PATTERN_CACHE.put(tplWithGroups, pattern); + } + } + + Matcher matcher = pattern.matcher(path); if(matcher.matches()) { List groupRefs = getGroupRefs(result);