Skip to content
This repository has been archived by the owner on Oct 1, 2020. It is now read-only.

Commit

Permalink
Avoid StringBuffer.
Browse files Browse the repository at this point in the history
  • Loading branch information
marchof committed Mar 14, 2016
1 parent 48ea912 commit 1d1c5cf
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public ICompilationUnit createCompilationUnit(
String pkgname = typepath.removeLastSegments(1).toString()
.replace('/', '.');
IPackageFragment fragment = createPackage(fragmentRoot, pkgname);
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
InputStream source = openTestResource(new Path(testsrc).append(typepath));
Reader r = new InputStreamReader(source);
int c;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,10 @@ public boolean isEnabled() {
}

public void trace(String message) {
StringBuffer sb = new StringBuffer();
sb.append('[').append(channel).append("] ").append(message); //$NON-NLS-1$
out.println(sb);
out.print("["); //$NON-NLS-1$
out.print(channel);
out.print("] "); //$NON-NLS-1$
out.println(message);
}

private void trace(String message, Object[] params) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static String getParameters(final IMethod method)
if (method.isBinary()) {
return getParameters(method.getSignature());
}
final StringBuffer buffer = new StringBuffer();
final StringBuilder buffer = new StringBuilder();
final String[] parameterTypes = method.getParameterTypes();
for (final String t : parameterTypes) {
resolveArrayParameterType(method, t, buffer);
Expand All @@ -63,7 +63,7 @@ public static String getParameters(final IMethod method)
}

private static final void resolveArrayParameterType(final IMethod method,
final String parameterType, final StringBuffer result)
final String parameterType, final StringBuilder result)
throws JavaModelException {
final int arrayCount = Signature.getArrayCount(parameterType);
for (int i = 0; i < arrayCount; i++) {
Expand All @@ -73,7 +73,7 @@ private static final void resolveArrayParameterType(final IMethod method,
}

private static final void resolveParameterType(final IMethod method,
final String parameterType, final StringBuffer result)
final String parameterType, final StringBuilder result)
throws JavaModelException {
final char kind = parameterType.charAt(0);
switch (kind) {
Expand All @@ -92,7 +92,7 @@ private static final void resolveParameterType(final IMethod method,
}

private static final boolean resolveType(final IType scope,
final String identifier, final StringBuffer result)
final String identifier, final StringBuilder result)
throws JavaModelException {
final String[][] types = scope.resolveType(Signature
.getTypeErasure(identifier));
Expand All @@ -111,7 +111,7 @@ private static final boolean resolveType(final IType scope,
}

private static final boolean resolveTypeParameter(final IMethod method,
final String identifier, final StringBuffer result)
final String identifier, final StringBuilder result)
throws JavaModelException {
IType type = method.getDeclaringType();
if (resolveTypeParameter(type, method.getTypeParameters(), identifier,
Expand All @@ -130,7 +130,7 @@ private static final boolean resolveTypeParameter(final IMethod method,

private static final boolean resolveTypeParameter(final IType context,
final ITypeParameter[] typeParameters, final String identifier,
final StringBuffer result) throws JavaModelException {
final StringBuilder result) throws JavaModelException {
for (final ITypeParameter p : typeParameters) {
if (identifier.equals(p.getElementName())) {
final String[] bounds = p.getBounds();
Expand All @@ -146,7 +146,7 @@ private static final boolean resolveTypeParameter(final IType context,
}

private static final void replace(final String source, final char oldChar,
final char newChar, final StringBuffer result) {
final char newChar, final StringBuilder result) {
final int len = source.length();
for (int i = 0; i < len; i++) {
final char c = source.charAt(i);
Expand Down

0 comments on commit 1d1c5cf

Please sign in to comment.