groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sun...@apache.org
Subject [3/4] groovy git commit: Trivial refactoring: avoid unnecessary `StringBuffer` usage
Date Fri, 06 Apr 2018 07:07:57 GMT
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/75b06256
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/75b06256
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/75b06256

Branch: refs/heads/GROOVY_2_6_X
Commit: 75b06256e9847925a2ffa5b2f1bbdd0b3507c228
Parents: 09070aa
Author: danielsun1106 <realbluesun@hotmail.com>
Authored: Fri Apr 6 14:49:28 2018 +0800
Committer: danielsun1106 <realbluesun@hotmail.com>
Committed: Fri Apr 6 15:07:38 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/75b06256/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;
     }
 


Mime
View raw message