mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-21 21:52:10 +02:00
Bug 492200 - Replace StringBuffer with StringBuilder where appropriate
Change-Id: Ib52b839a211e2068e56da4b62a5b9640fef55d40
This commit is contained in:
parent
6b0a04c15e
commit
9f79b897c1
5 changed files with 105 additions and 16 deletions
|
@ -31,7 +31,7 @@ public class HTMLPrinter {
|
|||
if (current == -1)
|
||||
return text;
|
||||
|
||||
StringBuffer buffer= new StringBuffer();
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
while (current > -1) {
|
||||
buffer.append(text.substring(previous, current));
|
||||
buffer.append(s);
|
||||
|
@ -50,7 +50,7 @@ public class HTMLPrinter {
|
|||
|
||||
public static String read(Reader rd) {
|
||||
|
||||
StringBuffer buffer= new StringBuffer();
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
char[] readBuffer= new char[2048];
|
||||
|
||||
try {
|
||||
|
@ -66,27 +66,27 @@ public class HTMLPrinter {
|
|||
return null;
|
||||
}
|
||||
|
||||
public static void insertPageProlog(StringBuffer buffer, int position) {
|
||||
public static void insertPageProlog(StringBuilder buffer, int position) {
|
||||
buffer.insert(position, "<html><body text=\"#000000\" bgcolor=\"#FFFF88\"><font size=-1>"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public static void addPageProlog(StringBuffer buffer) {
|
||||
public static void addPageProlog(StringBuilder buffer) {
|
||||
insertPageProlog(buffer, buffer.length());
|
||||
}
|
||||
|
||||
public static void addPageEpilog(StringBuffer buffer) {
|
||||
public static void addPageEpilog(StringBuilder buffer) {
|
||||
buffer.append("</font></body></html>"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public static void startBulletList(StringBuffer buffer) {
|
||||
public static void startBulletList(StringBuilder buffer) {
|
||||
buffer.append("<ul>"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public static void endBulletList(StringBuffer buffer) {
|
||||
public static void endBulletList(StringBuilder buffer) {
|
||||
buffer.append("</ul>"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public static void addBullet(StringBuffer buffer, String bullet) {
|
||||
public static void addBullet(StringBuilder buffer, String bullet) {
|
||||
if (bullet != null) {
|
||||
buffer.append("<li>"); //$NON-NLS-1$
|
||||
buffer.append(bullet);
|
||||
|
@ -94,7 +94,7 @@ public class HTMLPrinter {
|
|||
}
|
||||
}
|
||||
|
||||
public static void addSmallHeader(StringBuffer buffer, String header) {
|
||||
public static void addSmallHeader(StringBuilder buffer, String header) {
|
||||
if (header != null) {
|
||||
buffer.append("<h5>"); //$NON-NLS-1$
|
||||
buffer.append(header);
|
||||
|
@ -102,14 +102,15 @@ public class HTMLPrinter {
|
|||
}
|
||||
}
|
||||
|
||||
public static void addParagraph(StringBuffer buffer, String paragraph) {
|
||||
public static void addParagraph(StringBuilder buffer, String paragraph) {
|
||||
if (paragraph != null) {
|
||||
buffer.append("<p>"); //$NON-NLS-1$
|
||||
buffer.append(paragraph);
|
||||
}
|
||||
}
|
||||
|
||||
public static void addParagraph(StringBuffer buffer, Reader paragraphReader) {
|
||||
public static void addParagraph(StringBuilder buffer,
|
||||
Reader paragraphReader) {
|
||||
if (paragraphReader != null)
|
||||
addParagraph(buffer, read(paragraphReader));
|
||||
}
|
||||
|
|
|
@ -206,7 +206,7 @@ public class ListProblemPreference extends AbstractProblemPreference implements
|
|||
|
||||
@Override
|
||||
public String exportValue() {
|
||||
StringBuffer buf = new StringBuffer("("); //$NON-NLS-1$
|
||||
StringBuilder buf = new StringBuilder("("); //$NON-NLS-1$
|
||||
for (Iterator<Object> iterator = list.iterator(); iterator.hasNext();) {
|
||||
IProblemPreference d = (IProblemPreference) childDescriptor.clone();
|
||||
d.setValue(iterator.next());
|
||||
|
|
|
@ -463,13 +463,13 @@ public class Alignment {
|
|||
}
|
||||
}
|
||||
|
||||
public void toFragmentsString(StringBuffer buffer) {
|
||||
public void toFragmentsString(StringBuilder buffer) {
|
||||
// default implementation
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer buffer = new StringBuffer(10);
|
||||
StringBuilder buffer = new StringBuilder(10);
|
||||
buffer
|
||||
.append(getClass().getName())
|
||||
.append(':')
|
||||
|
|
|
@ -225,6 +225,10 @@ public class CPElement {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #appendEncodedPath(IPath, StringBuilder)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static StringBuffer appendEncodePath(IPath path, StringBuffer buf) {
|
||||
if (path != null) {
|
||||
String str = path.toString();
|
||||
|
@ -235,6 +239,10 @@ public class CPElement {
|
|||
return buf.append(';');
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #appendEncodedSettings(StringBuilder)}
|
||||
*/
|
||||
@Deprecated
|
||||
public StringBuffer appendEncodedSettings(StringBuffer buf) {
|
||||
buf.append(fEntryKind).append(';');
|
||||
appendEncodePath(fPath, buf).append(';');
|
||||
|
@ -305,6 +313,86 @@ public class CPElement {
|
|||
return buf;
|
||||
}
|
||||
|
||||
public static StringBuilder appendEncodedPath(IPath path, StringBuilder buf) {
|
||||
if (path != null) {
|
||||
String str = path.toString();
|
||||
buf.append('[').append(str.length()).append(']').append(str);
|
||||
} else {
|
||||
buf.append('[').append(']');
|
||||
}
|
||||
return buf.append(';');
|
||||
}
|
||||
|
||||
public StringBuilder appendEncodedSettings(StringBuilder buf) {
|
||||
buf.append(fEntryKind).append(';');
|
||||
appendEncodedPath(fPath, buf).append(';');
|
||||
buf.append(Boolean.valueOf(fIsExported)).append(';');
|
||||
switch (fEntryKind) {
|
||||
case IPathEntry.CDT_OUTPUT:
|
||||
case IPathEntry.CDT_SOURCE:
|
||||
case IPathEntry.CDT_INCLUDE:
|
||||
case IPathEntry.CDT_INCLUDE_FILE:
|
||||
case IPathEntry.CDT_MACRO:
|
||||
case IPathEntry.CDT_MACRO_FILE:
|
||||
IPath[] exclusion = (IPath[])getAttribute(EXCLUSION);
|
||||
buf.append('[').append(exclusion.length).append(']');
|
||||
for (IPath element : exclusion) {
|
||||
appendEncodedPath(element, buf);
|
||||
}
|
||||
switch (fEntryKind) {
|
||||
case IPathEntry.CDT_INCLUDE:
|
||||
IPath baseRef = (IPath)getAttribute(BASE_REF);
|
||||
appendEncodedPath(baseRef, buf);
|
||||
IPath base = (IPath)getAttribute(BASE);
|
||||
appendEncodedPath(base, buf);
|
||||
IPath include = (IPath)getAttribute(INCLUDE);
|
||||
appendEncodedPath(include, buf);
|
||||
break;
|
||||
case IPathEntry.CDT_INCLUDE_FILE:
|
||||
baseRef = (IPath)getAttribute(BASE_REF);
|
||||
appendEncodedPath(baseRef, buf);
|
||||
base = (IPath)getAttribute(BASE);
|
||||
appendEncodedPath(base, buf);
|
||||
IPath includeFile = (IPath)getAttribute(INCLUDE_FILE);
|
||||
appendEncodedPath(includeFile, buf);
|
||||
break;
|
||||
case IPathEntry.CDT_MACRO:
|
||||
baseRef = (IPath)getAttribute(BASE_REF);
|
||||
appendEncodedPath(baseRef, buf);
|
||||
base = (IPath)getAttribute(BASE);
|
||||
appendEncodedPath(base, buf);
|
||||
String symbol = (String)getAttribute(MACRO_NAME);
|
||||
buf.append(symbol).append(';');
|
||||
break;
|
||||
case IPathEntry.CDT_MACRO_FILE:
|
||||
baseRef = (IPath)getAttribute(BASE_REF);
|
||||
appendEncodedPath(baseRef, buf);
|
||||
base = (IPath)getAttribute(BASE);
|
||||
appendEncodedPath(base, buf);
|
||||
IPath macrosFile = (IPath)getAttribute(MACROS_FILE);
|
||||
appendEncodedPath(macrosFile, buf);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case IPathEntry.CDT_LIBRARY:
|
||||
IPath baseRef = (IPath)getAttribute(BASE_REF);
|
||||
appendEncodedPath(baseRef, buf);
|
||||
IPath base = (IPath)getAttribute(BASE);
|
||||
appendEncodedPath(base, buf);
|
||||
IPath sourceAttach = (IPath)getAttribute(SOURCEATTACHMENT);
|
||||
appendEncodedPath(sourceAttach, buf);
|
||||
IPath library = (IPath)getAttribute(LIBRARY);
|
||||
appendEncodedPath(library, buf);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
buf.setLength(buf.length() - 1);
|
||||
return buf;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the path entry path.
|
||||
*
|
||||
|
|
|
@ -399,7 +399,7 @@ public abstract class AbstractCLaunchDelegate2 extends LaunchConfigurationDelega
|
|||
|
||||
/** TODO: Temporarily duplicated from BuilderFactory. Remove when 313927 is addressed */
|
||||
private static String encodeList(List<String> values) {
|
||||
StringBuffer str = new StringBuffer();
|
||||
StringBuilder str = new StringBuilder();
|
||||
Iterator<String> entries = values.iterator();
|
||||
while (entries.hasNext()) {
|
||||
String entry = entries.next();
|
||||
|
@ -411,7 +411,7 @@ public abstract class AbstractCLaunchDelegate2 extends LaunchConfigurationDelega
|
|||
|
||||
/** TODO: Temporarily duplicated from BuilderFactory. Remove when 313927 is addressed */
|
||||
private static String escapeChars(String string, String escapeChars, char escapeChar) {
|
||||
StringBuffer str = new StringBuffer(string);
|
||||
StringBuilder str = new StringBuilder(string);
|
||||
for (int i = 0; i < str.length(); i++) {
|
||||
if (escapeChars.indexOf(str.charAt(i)) != -1) {
|
||||
str.insert(i, escapeChar);
|
||||
|
|
Loading…
Add table
Reference in a new issue