groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sun...@apache.org
Subject groovy git commit: Trivial refactoring for `groovy.lang.GString.appendStrings`
Date Tue, 02 Jan 2018 00:33:15 GMT
Repository: groovy
Updated Branches:
  refs/heads/master 3c91bc1fd -> 226384877


Trivial refactoring for `groovy.lang.GString.appendStrings`


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

Branch: refs/heads/master
Commit: 2263848771e69ae7187bdcf8fc56af968cfdcf1b
Parents: 3c91bc1
Author: sunlan <sunlan@apache.org>
Authored: Tue Jan 2 08:33:08 2018 +0800
Committer: sunlan <sunlan@apache.org>
Committed: Tue Jan 2 08:33:08 2018 +0800

----------------------------------------------------------------------
 src/main/groovy/groovy/lang/GString.java | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/22638487/src/main/groovy/groovy/lang/GString.java
----------------------------------------------------------------------
diff --git a/src/main/groovy/groovy/lang/GString.java b/src/main/groovy/groovy/lang/GString.java
index 54ae7d3..b9c26d0 100644
--- a/src/main/groovy/groovy/lang/GString.java
+++ b/src/main/groovy/groovy/lang/GString.java
@@ -99,7 +99,6 @@ public abstract class GString extends GroovyObjectSupport implements Comparable,
     private String[] appendStrings(String[] strings, String[] thatStrings, int valuesLength)
{
         int stringsLength = strings.length;
         boolean isStringsLonger = stringsLength > valuesLength;
-        int lastIndexOfStrings = stringsLength - 1;
         int thatStringsLength = isStringsLonger ? thatStrings.length - 1 : thatStrings.length;
 
         String[] newStrings = new String[stringsLength + thatStringsLength];
@@ -108,6 +107,8 @@ public abstract class GString extends GroovyObjectSupport implements Comparable,
         if (isStringsLonger) {
             // merge onto end of previous GString to avoid an empty bridging value
             System.arraycopy(thatStrings, 1, newStrings, stringsLength, thatStringsLength);
+
+            int lastIndexOfStrings = stringsLength - 1;
             newStrings[lastIndexOfStrings] = strings[lastIndexOfStrings] + thatStrings[0];
         } else {
             System.arraycopy(thatStrings, 0, newStrings, stringsLength, thatStringsLength);


Mime
View raw message