Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Blewitt2016-04-22 19:00:51 -0400
committerSergey Prigogin2016-04-25 12:38:47 -0400
commit6bdca5f4a2598b1206d51a59b720314a2f7aa3c1 (patch)
tree6c94852b1cf0abc24dcb1af3ef1526e89314bbe2 /build/org.eclipse.cdt.autotools.core/src
parente21fc12f9052e99dcf545df4a2ae2aba1c90c1cc (diff)
downloadorg.eclipse.cdt-6bdca5f4a2598b1206d51a59b720314a2f7aa3c1.tar.gz
org.eclipse.cdt-6bdca5f4a2598b1206d51a59b720314a2f7aa3c1.tar.xz
org.eclipse.cdt-6bdca5f4a2598b1206d51a59b720314a2f7aa3c1.zip
Bug 492230 - Replace buffer.append(a+b) calls
When using a `StringBuilder` or `StringBuffer` to create a string message, using implicit string concatenation inside an `.append()` call will create a nested StringBuilder for the purposes of creating the arguments, which will subsequently be converted to a String and then passed to the outer StringBuilder. Skip the creation of the intermediate object and String by simply replacing such calls with `buffer.append(a).append(b)`. Where values are compile time String constants, leave as is so that the javac compiler can perform compile-time String concatenation. Ensure that NEWLINE isn't appended in such a way since it is not a compile time constant `System.getProperty("line.separator")` Change-Id: I4126aefb2272f06b08332e004d7ea76b6f02cdba Signed-off-by: Alex Blewitt <alex.blewitt@gmail.com>
Diffstat (limited to 'build/org.eclipse.cdt.autotools.core/src')
-rw-r--r--build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/AutotoolsConfiguration.java4
-rw-r--r--build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/FlagConfigureOption.java10
2 files changed, 7 insertions, 7 deletions
diff --git a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/AutotoolsConfiguration.java b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/AutotoolsConfiguration.java
index f3e4162b8c..065bd712b1 100644
--- a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/AutotoolsConfiguration.java
+++ b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/AutotoolsConfiguration.java
@@ -303,12 +303,12 @@ public class AutotoolsConfiguration implements IAConfiguration {
IConfigureOption childOption = getOption(childOptions[j].getName());
String parameter = childOption.getParameter();
if (!parameter.isEmpty())
- buf.append(" " + parameter);
+ buf.append(' ').append(parameter);
}
} else {
String parameter = option.getParameter();
if (!parameter.isEmpty())
- buf.append(" " + parameter);
+ buf.append(' ').append(parameter);
}
}
return buf.toString();
diff --git a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/FlagConfigureOption.java b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/FlagConfigureOption.java
index e2066d5e2b..6abc667257 100644
--- a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/FlagConfigureOption.java
+++ b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/FlagConfigureOption.java
@@ -44,23 +44,23 @@ public class FlagConfigureOption extends AbstractConfigurationOption {
for (String flagName : flagNames) {
parms.append(flagSeparator);
flagSeparator = " "; //$NON-NLS-1$
- StringBuilder parm = new StringBuilder(flagName+"=\""); //$NON-NLS-1$
+ StringBuilder parm = new StringBuilder(flagName).append("=\""); //$NON-NLS-1$
boolean haveParm = false;
if (isParmSet()) {
- String separator = "";
+ String separator = ""; //$NON-NLS-1$
for (int i = 0; i < children.size(); ++i) {
String fvname = children.get(i);
IConfigureOption o = cfg.getOption(fvname);
if (o.isParmSet()) {
if (o instanceof IFlagConfigureValueOption) {
- parm.append(separator + ((IFlagConfigureValueOption)o).getFlags()); //$NON-NLS-1$
- separator = " ";
+ parm.append(separator).append(((IFlagConfigureValueOption)o).getFlags());
+ separator = " "; //$NON-NLS-1$
haveParm = true;
}
}
}
if (haveParm) {
- parm.append("\""); //$NON-NLS-1$
+ parm.append('"');
parms.append(parm);
}
}

Back to the top