Trivial refactoring: avoid unnecessary `StringBuffer` usage

Java compiler will optimize strings concatenation

(cherry picked from commit 79d90ec)


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/852d1e89
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/852d1e89
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/852d1e89

Branch: refs/heads/GROOVY_2_5_X
Commit: 852d1e89d28bb504b98206176517457ab52a3cf5
Parents: 9042e3d
Author: danielsun1106 <realblue...@hotmail.com>
Authored: Fri Apr 6 14:49:28 2018 +0800
Committer: danielsun1106 <realblue...@hotmail.com>
Committed: Fri Apr 6 15:08:43 2018 +0800

----------------------------------------------------------------------
 .../java/org/codehaus/groovy/control/ResolveVisitor.java     | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/852d1e89/src/main/java/org/codehaus/groovy/control/ResolveVisitor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/control/ResolveVisitor.java 
b/src/main/java/org/codehaus/groovy/control/ResolveVisitor.java
index bc3630f..20d4f8f 100644
--- a/src/main/java/org/codehaus/groovy/control/ResolveVisitor.java
+++ b/src/main/java/org/codehaus/groovy/control/ResolveVisitor.java
@@ -460,11 +460,9 @@ public class ResolveVisitor extends 
ClassCodeExpressionTransformer {
 
     private static String replaceLastPoint(String name) {
         int lastPoint = name.lastIndexOf('.');
-        name = new StringBuffer()
-                .append(name.substring(0, lastPoint))
-                .append("$")
-                .append(name.substring(lastPoint + 1))
-                .toString();
+        name = name.substring(0, lastPoint) +
+                "$" +
+                name.substring(lastPoint + 1);
         return name;
     }
 

Reply via email to