diff options
author | Andrey Turbanov <turbanoff@gmail.com> | 2021-11-20 17:16:22 +0300 |
---|---|---|
committer | Andrey Turbanov <turbanoff@gmail.com> | 2021-11-20 17:22:06 +0300 |
commit | b1c52e2f5eb624037b8c799c20fbd1b4fd611d9a (patch) | |
tree | 33d7b6e8f733f20514f46e7871b29e26de47913d /bridge/src | |
parent | 0f85ca109b9e6ab849e201e76f62d5023cbfcb98 (diff) | |
download | aspectj-b1c52e2f5eb624037b8c799c20fbd1b4fd611d9a.tar.gz aspectj-b1c52e2f5eb624037b8c799c20fbd1b4fd611d9a.zip |
Replace uses of StringBuffer with StringBuilder.
StringBuffer is a legacy synchronized class. StringBuilder is a direct replacement to StringBuffer which generally have better performance.
Diffstat (limited to 'bridge/src')
6 files changed, 10 insertions, 10 deletions
diff --git a/bridge/src/main/java/org/aspectj/bridge/MessageUtil.java b/bridge/src/main/java/org/aspectj/bridge/MessageUtil.java index 8c17cd947..0a765e503 100644 --- a/bridge/src/main/java/org/aspectj/bridge/MessageUtil.java +++ b/bridge/src/main/java/org/aspectj/bridge/MessageUtil.java @@ -851,7 +851,7 @@ public class MessageUtil { if (null == loc) { return "((ISourceLocation) null)"; } - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); File sourceFile = loc.getSourceFile(); if (sourceFile != ISourceLocation.NO_FILE) { @@ -901,7 +901,7 @@ public class MessageUtil { Throwable thrown = message.getThrown(); ISourceLocation sl = message.getSourceLocation(); IMessage.Kind kind = message.getKind(); - StringBuffer result = new StringBuffer(); + StringBuilder result = new StringBuilder(); result.append(kind.toString()); result.append(": "); if (null != thrown) { @@ -988,7 +988,7 @@ public class MessageUtil { if (0 == holder.numMessages(null, false)) { return "(0 messages)"; } - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); for (IMessage.Kind kind : IMessage.KINDS) { int num = holder.numMessages(kind, false); if (0 < num) { diff --git a/bridge/src/main/java/org/aspectj/bridge/SourceLocation.java b/bridge/src/main/java/org/aspectj/bridge/SourceLocation.java index e6cbe0bc2..88bcd4b48 100644 --- a/bridge/src/main/java/org/aspectj/bridge/SourceLocation.java +++ b/bridge/src/main/java/org/aspectj/bridge/SourceLocation.java @@ -131,7 +131,7 @@ public class SourceLocation implements ISourceLocation { /** @return String {context\n}{file:}line{:column} */ public String toString() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); if (null != context) { sb.append(context); sb.append(LangUtil.EOL); diff --git a/bridge/src/main/java/org/aspectj/bridge/WeaveMessage.java b/bridge/src/main/java/org/aspectj/bridge/WeaveMessage.java index ba6baab5b..454a3e6be 100644 --- a/bridge/src/main/java/org/aspectj/bridge/WeaveMessage.java +++ b/bridge/src/main/java/org/aspectj/bridge/WeaveMessage.java @@ -57,7 +57,7 @@ public class WeaveMessage extends Message { * @return new weaving message */ public static WeaveMessage constructWeavingMessage(WeaveMessageKind kind, String[] inserts) { - StringBuffer str = new StringBuffer(kind.getMessage()); + StringBuilder str = new StringBuilder(kind.getMessage()); int pos = -1; while ((pos = new String(str).indexOf("%")) != -1) { int n = Character.getNumericValue(str.charAt(pos + 1)); @@ -77,7 +77,7 @@ public class WeaveMessage extends Message { */ public static WeaveMessage constructWeavingMessage(WeaveMessageKind kind, String[] inserts, String affectedtypename, String aspectname) { - StringBuffer str = new StringBuffer(kind.getMessage()); + StringBuilder str = new StringBuilder(kind.getMessage()); int pos = -1; while ((pos = new String(str).indexOf("%")) != -1) { int n = Character.getNumericValue(str.charAt(pos + 1)); diff --git a/bridge/src/main/java/org/aspectj/bridge/context/CompilationAndWeavingContext.java b/bridge/src/main/java/org/aspectj/bridge/context/CompilationAndWeavingContext.java index cd750e4ab..bfb8ec190 100644 --- a/bridge/src/main/java/org/aspectj/bridge/context/CompilationAndWeavingContext.java +++ b/bridge/src/main/java/org/aspectj/bridge/context/CompilationAndWeavingContext.java @@ -138,7 +138,7 @@ public class CompilationAndWeavingContext { explanationStack.push(getFormatter(entry).formatEntry(entry.phaseId, data)); } } - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); while (!explanationStack.isEmpty()) { sb.append("when "); sb.append(explanationStack.pop().toString()); @@ -240,7 +240,7 @@ public class CompilationAndWeavingContext { private static class DefaultFormatter implements ContextFormatter { public String formatEntry(int phaseId, Object data) { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append(PHASE_NAMES[phaseId]); sb.append(" "); if (data instanceof char[]) { diff --git a/bridge/src/main/java/org/aspectj/bridge/context/PinpointingMessageHandler.java b/bridge/src/main/java/org/aspectj/bridge/context/PinpointingMessageHandler.java index fe2239d7a..c041adf65 100644 --- a/bridge/src/main/java/org/aspectj/bridge/context/PinpointingMessageHandler.java +++ b/bridge/src/main/java/org/aspectj/bridge/context/PinpointingMessageHandler.java @@ -44,7 +44,7 @@ public class PinpointingMessageHandler implements IMessageHandler { ex.fillInStackTrace(); StringWriter sw = new StringWriter(); ex.printStackTrace(new PrintWriter(sw)); - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append(CompilationAndWeavingContext.getCurrentContext()); sb.append(sw.toString()); IMessage pinpointedMessage = new PinpointedMessage(message,sb.toString()); diff --git a/bridge/src/test/java/org/aspectj/bridge/MessageTest.java b/bridge/src/test/java/org/aspectj/bridge/MessageTest.java index c4e6b6a3c..b36442afb 100644 --- a/bridge/src/test/java/org/aspectj/bridge/MessageTest.java +++ b/bridge/src/test/java/org/aspectj/bridge/MessageTest.java @@ -286,7 +286,7 @@ class KindTest { /** @return error if failed */ String checkExpectedKind(IMessage m) { - StringBuffer result = new StringBuffer(); + StringBuilder result = new StringBuilder(); for (int i = 0; i < KINDS.length; i++) { if (expected.get(i) != checkKindMethods(m, i)) { String s = "expected " + expected.get(i) |