This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-lang.git
The following commit(s) were added to refs/heads/master by this push: new eafdd08 LANG-1437: Remove redundant if statements in join methods (#411) eafdd08 is described below commit eafdd08e2096e15e16182096d94fa37e72ae908b Author: Andrei Troie <andreitroi...@gmail.com> AuthorDate: Mon Aug 19 20:30:22 2019 +0100 LANG-1437: Remove redundant if statements in join methods (#411) --- .../java/org/apache/commons/lang3/StringUtils.java | 69 +++++++++++----------- 1 file changed, 33 insertions(+), 36 deletions(-) diff --git a/src/main/java/org/apache/commons/lang3/StringUtils.java b/src/main/java/org/apache/commons/lang3/StringUtils.java index a5f90a1..f76e470 100644 --- a/src/main/java/org/apache/commons/lang3/StringUtils.java +++ b/src/main/java/org/apache/commons/lang3/StringUtils.java @@ -3852,10 +3852,9 @@ public class StringUtils { return EMPTY; } final StringBuilder buf = newStringBuilder(noOfItems); - for (int i = startIndex; i < endIndex; i++) { - if (i > startIndex) { - buf.append(separator); - } + buf.append(array[startIndex]); + for (int i = startIndex + 1; i < endIndex; i++) { + buf.append(separator); buf.append(array[i]); } return buf.toString(); @@ -3933,10 +3932,9 @@ public class StringUtils { return EMPTY; } final StringBuilder buf = newStringBuilder(noOfItems); - for (int i = startIndex; i < endIndex; i++) { - if (i > startIndex) { - buf.append(separator); - } + buf.append(array[startIndex]); + for (int i = startIndex + 1; i < endIndex; i++) { + buf.append(separator); buf.append(array[i]); } return buf.toString(); @@ -4014,10 +4012,9 @@ public class StringUtils { return EMPTY; } final StringBuilder buf = newStringBuilder(noOfItems); - for (int i = startIndex; i < endIndex; i++) { - if (i > startIndex) { - buf.append(separator); - } + buf.append(array[startIndex]); + for (int i = startIndex + 1; i < endIndex; i++) { + buf.append(separator); buf.append(array[i]); } return buf.toString(); @@ -4095,10 +4092,9 @@ public class StringUtils { return EMPTY; } final StringBuilder buf = newStringBuilder(noOfItems); - for (int i = startIndex; i < endIndex; i++) { - if (i > startIndex) { - buf.append(separator); - } + buf.append(array[startIndex]); + for (int i = startIndex + 1; i < endIndex; i++) { + buf.append(separator); buf.append(array[i]); } return buf.toString(); @@ -4176,10 +4172,9 @@ public class StringUtils { return EMPTY; } final StringBuilder buf = newStringBuilder(noOfItems); - for (int i = startIndex; i < endIndex; i++) { - if (i > startIndex) { - buf.append(separator); - } + buf.append(array[startIndex]); + for (int i = startIndex + 1; i < endIndex; i++) { + buf.append(separator); buf.append(array[i]); } return buf.toString(); @@ -4466,10 +4461,9 @@ public class StringUtils { return EMPTY; } final StringBuilder buf = newStringBuilder(noOfItems); - for (int i = startIndex; i < endIndex; i++) { - if (i > startIndex) { - buf.append(separator); - } + buf.append(array[startIndex]); + for (int i = startIndex + 1; i < endIndex; i++) { + buf.append(separator); buf.append(array[i]); } return buf.toString(); @@ -4539,10 +4533,11 @@ public class StringUtils { return EMPTY; } final StringBuilder buf = newStringBuilder(noOfItems); - for (int i = startIndex; i < endIndex; i++) { - if (i > startIndex) { - buf.append(separator); - } + if (array[startIndex] != null) { + buf.append(array[startIndex]); + } + for (int i = startIndex + 1; i < endIndex; i++) { + buf.append(separator); if (array[i] != null) { buf.append(array[i]); } @@ -4632,10 +4627,13 @@ public class StringUtils { final StringBuilder buf = newStringBuilder(noOfItems); - for (int i = startIndex; i < endIndex; i++) { - if (i > startIndex) { - buf.append(separator); - } + if (array[startIndex] != null) { + buf.append(array[startIndex]); + } + + for (int i = startIndex + 1; i < endIndex; i++) { + buf.append(separator); + if (array[i] != null) { buf.append(array[i]); } @@ -4715,10 +4713,9 @@ public class StringUtils { return EMPTY; } final StringBuilder buf = newStringBuilder(noOfItems); - for (int i = startIndex; i < endIndex; i++) { - if (i > startIndex) { - buf.append(separator); - } + buf.append(array[startIndex]); + for (int i = startIndex + 1; i < endIndex; i++) { + buf.append(separator); buf.append(array[i]); } return buf.toString();