Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc-Andre Laperle2020-08-16 19:45:38 -0400
committerMarc-André Laperle2020-08-23 23:18:40 -0400
commita9b67d0828267919e63c3ef78da24db936e45a25 (patch)
tree3695984fe03276ac0fc7d25475283921bc5d3fdb /windows/org.eclipse.cdt.msw.build/src/org/eclipse
parent68c9b53de068aa58b95403dd3b1babe741d6fb09 (diff)
downloadorg.eclipse.cdt-a9b67d0828267919e63c3ef78da24db936e45a25.tar.gz
org.eclipse.cdt-a9b67d0828267919e63c3ef78da24db936e45a25.tar.xz
org.eclipse.cdt-a9b67d0828267919e63c3ef78da24db936e45a25.zip
Bug 565553 - Improve performance of build command parsers with large number of files
Optimize MSVCBuildCommandParser.unescapeString. Instead of running a Matcher/replaceAll every time, check first if the string contains the characters to unescape first. Finding a substring in a string is much faster than matching a pattern so this saves quite a bit of time on large MSVC projects since many options will not have the characters needed to be unescaped. Change-Id: If2ad7892c29374458d5de446d4492ce3ba576c9c Signed-off-by: Marc-Andre Laperle <malaperle@gmail.com>
Diffstat (limited to 'windows/org.eclipse.cdt.msw.build/src/org/eclipse')
-rw-r--r--windows/org.eclipse.cdt.msw.build/src/org/eclipse/cdt/msw/build/core/MSVCBuildCommandParser.java13
1 files changed, 11 insertions, 2 deletions
diff --git a/windows/org.eclipse.cdt.msw.build/src/org/eclipse/cdt/msw/build/core/MSVCBuildCommandParser.java b/windows/org.eclipse.cdt.msw.build/src/org/eclipse/cdt/msw/build/core/MSVCBuildCommandParser.java
index 50d2a814f33..8089a8e6271 100644
--- a/windows/org.eclipse.cdt.msw.build/src/org/eclipse/cdt/msw/build/core/MSVCBuildCommandParser.java
+++ b/windows/org.eclipse.cdt.msw.build/src/org/eclipse/cdt/msw/build/core/MSVCBuildCommandParser.java
@@ -26,11 +26,20 @@ import org.eclipse.cdt.managedbuilder.language.settings.providers.AbstractBuildC
*/
public class MSVCBuildCommandParser extends AbstractBuildCommandParser implements ILanguageSettingsEditableProvider {
+ private static final String DOUBLE_BACKSLASH = "\\\\"; //$NON-NLS-1$
+ private static final Pattern DOUBLE_BACKSLASH_PATTERN = Pattern.compile(Pattern.quote(DOUBLE_BACKSLASH));
+ private static final String BACKSLASH_REPLACEMENT_STRING = "\\\\"; //$NON-NLS-1$
+ private static final String BACKSLASH_QUOTE = "\\\""; //$NON-NLS-1$
+ private static final Pattern BACKSLASH_QUOTE_PATTERN = Pattern.compile(Pattern.quote(BACKSLASH_QUOTE));
+ private static final String QUOTE_REPLACEMENT_STRING = "\""; //$NON-NLS-1$
+
private static String unescapeString(String value) {
// There are probably many other things to unescape but these are the most
// common.
- value = value.replaceAll("\\\\\\\\", "\\\\"); //$NON-NLS-1$//$NON-NLS-2$
- value = value.replaceAll("\\\\\"", "\""); //$NON-NLS-1$ //$NON-NLS-2$
+ if (value.contains(DOUBLE_BACKSLASH))
+ value = DOUBLE_BACKSLASH_PATTERN.matcher(value).replaceAll(BACKSLASH_REPLACEMENT_STRING);
+ if (value.contains(BACKSLASH_QUOTE))
+ value = BACKSLASH_QUOTE_PATTERN.matcher(value).replaceAll(QUOTE_REPLACEMENT_STRING);
return value;
}

Back to the top