Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc-Andre Laperle2020-07-31 16:23:33 -0400
committerMarc-André Laperle2020-08-23 23:21:14 -0400
commite933f46289c9e7c08356128c9c10abd1892a2b7a (patch)
treee76abdb15a59ed69eec834fcb9908c3b08c1d4e8 /build/org.eclipse.cdt.managedbuilder.core/src
parenta9b67d0828267919e63c3ef78da24db936e45a25 (diff)
downloadorg.eclipse.cdt-e933f46289c9e7c08356128c9c10abd1892a2b7a.tar.gz
org.eclipse.cdt-e933f46289c9e7c08356128c9c10abd1892a2b7a.tar.xz
org.eclipse.cdt-e933f46289c9e7c08356128c9c10abd1892a2b7a.zip
Bug 565553 - Improve performance of build command parsers with large number of files
Compile a pattern ahead of time and early return. The first pattern is used to trim extra characters that are not contained within the actual option pattern. If this first pattern doesn't match, there is no point in continuing because it is a superset. Times before/after, only counting AbstractOptionParser.parseOption LLVM before: 4289ms, after: 622ms Change-Id: Id40fc9a35359c39aea00ba14813ffe6c343158fc Signed-off-by: Marc-Andre Laperle <malaperle@gmail.com>
Diffstat (limited to 'build/org.eclipse.cdt.managedbuilder.core/src')
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/language/settings/providers/AbstractLanguageSettingsOutputScanner.java12
1 files changed, 8 insertions, 4 deletions
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/language/settings/providers/AbstractLanguageSettingsOutputScanner.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/language/settings/providers/AbstractLanguageSettingsOutputScanner.java
index 10b8a51f64e..854c38a1052 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/language/settings/providers/AbstractLanguageSettingsOutputScanner.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/language/settings/providers/AbstractLanguageSettingsOutputScanner.java
@@ -145,7 +145,6 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett
*/
protected static abstract class AbstractOptionParser {
private final int kind;
- private final String patternStr;
private final Pattern pattern;
private final String nameExpression;
private final String valueExpression;
@@ -153,6 +152,7 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett
private String parsedName;
private String parsedValue;
+ private final Pattern removeExtraFileNamePattern;
/**
* Constructor.
@@ -168,12 +168,12 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett
public AbstractOptionParser(int kind, String pattern, String nameExpression, String valueExpression,
int extraFlag) {
this.kind = kind;
- this.patternStr = pattern;
this.nameExpression = nameExpression;
this.valueExpression = valueExpression;
this.extraFlag = extraFlag;
this.pattern = Pattern.compile(pattern);
+ this.removeExtraFileNamePattern = Pattern.compile("(" + pattern + ").*"); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
@@ -225,8 +225,12 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett
*/
public boolean parseOption(String optionString) {
// get rid of extra text at the end (for example file name could be confused for an argument)
- @SuppressWarnings("nls")
- String option = optionString.replaceFirst("(" + patternStr + ").*", "$1");
+ Matcher matcherRemoveExtra = removeExtraFileNamePattern.matcher(optionString);
+ String option = optionString;
+ if (!matcherRemoveExtra.matches()) {
+ return false;
+ }
+ option = matcherRemoveExtra.group(1);
Matcher matcher = pattern.matcher(option);
boolean isMatch = matcher.matches();

Back to the top