Return-Path: X-Original-To: archive-asf-public@eu.ponee.io Delivered-To: archive-asf-public@eu.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by mx-eu-01.ponee.io (Postfix) with ESMTP id 505FA18075F for ; Tue, 2 Jan 2018 01:33:17 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 4065E160C37; Tue, 2 Jan 2018 00:33:17 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 86ECA160C25 for ; Tue, 2 Jan 2018 01:33:16 +0100 (CET) Received: (qmail 14661 invoked by uid 500); 2 Jan 2018 00:33:15 -0000 Mailing-List: contact commits-help@groovy.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@groovy.apache.org Delivered-To: mailing list commits@groovy.apache.org Received: (qmail 14652 invoked by uid 99); 2 Jan 2018 00:33:15 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 Jan 2018 00:33:15 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 863A0DFCFA; Tue, 2 Jan 2018 00:33:15 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sunlan@apache.org To: commits@groovy.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: groovy git commit: Trivial refactoring for `groovy.lang.GString.appendStrings` Date: Tue, 2 Jan 2018 00:33:15 +0000 (UTC) archived-at: Tue, 02 Jan 2018 00:33:17 -0000 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 Authored: Tue Jan 2 08:33:08 2018 +0800 Committer: sunlan 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);