From c7104fc481399809df19d6adf3ab2243eedbe486 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 5 May 2026 01:05:10 +0000 Subject: [PATCH 1/2] =?UTF-8?q?=E2=9A=A1=20Bolt:=20Optimize=20String=20rep?= =?UTF-8?q?lacements=20in=20FileNameEvaluation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replaces regex `Pattern.matcher(pattern).replaceAll(replacement)` with standard `String.replace(target, replacement)` for literal string replacements. This avoids the overhead of regex compilation and `Matcher` instantiation in Java. Cleaned up unused `Pattern` constants and imports. Co-authored-by: RoiSoleil <3462260+RoiSoleil@users.noreply.github.com> --- .../moreunit/core/matching/FileNameEvaluation.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/org.moreunit.core/src/org/moreunit/core/matching/FileNameEvaluation.java b/org.moreunit.core/src/org/moreunit/core/matching/FileNameEvaluation.java index 47c8533f..99c91ae0 100644 --- a/org.moreunit.core/src/org/moreunit/core/matching/FileNameEvaluation.java +++ b/org.moreunit.core/src/org/moreunit/core/matching/FileNameEvaluation.java @@ -3,7 +3,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; -import java.util.regex.Pattern; import org.moreunit.core.util.StringConstants; @@ -21,10 +20,6 @@ */ public final class FileNameEvaluation { - private static final Pattern QUOTE_SEPARATORS = Pattern.compile("(?:\\\\Q|\\\\E)"); - private static final Pattern SUCCESSIVE_QUOTE_SEPARATORS = Pattern.compile("\\\\E\\\\Q"); - private static final Pattern WILDCARDS = Pattern.compile("\\.\\*"); - private final String evaluatedFileName; private final boolean testFile; private final Collection otherCorrespondingFilePatterns; @@ -45,7 +40,8 @@ private static Collection simplify(Collection patterns) List result = new ArrayList(); for (String pattern : patterns) { - result.add(SUCCESSIVE_QUOTE_SEPARATORS.matcher(pattern).replaceAll("")); + // Bolt performance optimization: use String.replace for simple literal replacements instead of regex matchers. + result.add(pattern.replace("\\E\\Q", "")); } return result; } @@ -83,7 +79,8 @@ public List getAllCorrespondingFileEclipsePatterns() private String convertWildcards(String str) { - return WILDCARDS.matcher(str).replaceAll("*"); + // Bolt performance optimization: use String.replace for literal replacements instead of regex Pattern compilation/evaluation. + return str.replace(".*", "*"); } /** @@ -126,7 +123,8 @@ public String getPreferredCorrespondingFileName() private String removeQuotes(String str) { - return QUOTE_SEPARATORS.matcher(str).replaceAll(""); + // Bolt performance optimization: chained String.replace avoids Matcher allocations and is significantly faster than regex parsing for static literals. + return str.replace("\\Q", "").replace("\\E", ""); } @Override From 258d8c03807d2951f9bac9a4a356ce554627e5d2 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 5 May 2026 01:24:59 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=E2=9A=A1=20Bolt:=20Optimize=20String=20rep?= =?UTF-8?q?lacements=20in=20FileNameEvaluation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replaces regex `Pattern.matcher(pattern).replaceAll(replacement)` with standard `String.replace(target, replacement)` for literal string replacements. This avoids the overhead of regex compilation and `Matcher` instantiation in Java. Cleaned up unused `Pattern` constants and imports. Co-authored-by: RoiSoleil <3462260+RoiSoleil@users.noreply.github.com> --- .../moreunit/core/matching/FileNameEvaluationTest.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/org.moreunit.core.test/test/org/moreunit/core/matching/FileNameEvaluationTest.java b/org.moreunit.core.test/test/org/moreunit/core/matching/FileNameEvaluationTest.java index 88be55cf..89da9c03 100644 --- a/org.moreunit.core.test/test/org/moreunit/core/matching/FileNameEvaluationTest.java +++ b/org.moreunit.core.test/test/org/moreunit/core/matching/FileNameEvaluationTest.java @@ -42,4 +42,14 @@ public void should_convert_regex_to_eclipse_search_pattern() throws Exception // then assertThat(eval.getAllCorrespondingFileEclipsePatterns()).containsExactly("Pre*File*Suf", "Pre*File", "File*Suf"); } + + @Test + public void should_simplify_successive_quote_separators() throws Exception + { + // given + FileNameEvaluation eval = new FileNameEvaluation("Irrelevant", false, "PreFileSuf", asList("\\QPre\\E\\QFile\\E"), NO_PATTERNS); + + // then + assertThat(eval.getAllCorrespondingFilePatterns()).containsExactly("\\QPreFile\\E"); + } }