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 44d4acc Simplify some usages of the ternary operator with calls to Math.max() and Math.min(). (#512) 44d4acc is described below commit 44d4acc6218bf06843833eaf275ccf5f2d526999 Author: Isira Seneviratne <31027858+isira-senevira...@users.noreply.github.com> AuthorDate: Mon Apr 20 20:57:41 2020 +0000 Simplify some usages of the ternary operator with calls to Math.max() and Math.min(). (#512) --- src/main/java/org/apache/commons/lang3/StringUtils.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/apache/commons/lang3/StringUtils.java b/src/main/java/org/apache/commons/lang3/StringUtils.java index 3caf9e1..4f20fd8 100644 --- a/src/main/java/org/apache/commons/lang3/StringUtils.java +++ b/src/main/java/org/apache/commons/lang3/StringUtils.java @@ -6421,9 +6421,8 @@ public class StringUtils { return text; } final int replLength = searchString.length(); - int increase = replacement.length() - replLength; - increase = increase < 0 ? 0 : increase; - increase *= max < 0 ? 16 : max > 64 ? 64 : max; + int increase = Math.max(replacement.length() - replLength, 0); + increase *= max < 0 ? 16 : Math.min(max, 64); final StringBuilder buf = new StringBuilder(text.length() + increase); while (end != INDEX_NOT_FOUND) { buf.append(text, start, end).append(replacement); @@ -9168,7 +9167,7 @@ public class StringUtils { return EMPTY; } if (str.length() > maxWidth) { - final int ix = offset + maxWidth > str.length() ? str.length() : offset + maxWidth; + final int ix = Math.min(offset + maxWidth, str.length()); return str.substring(offset, ix); } return str.substring(offset);