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 9078cdc use_Math_max_min (#547) 9078cdc is described below commit 9078cdc8c4320296219a42efa304b21d2e87f0e2 Author: XenoAmess <xenoam...@gmail.com> AuthorDate: Sat Jun 13 22:49:59 2020 +0800 use_Math_max_min (#547) --- src/main/java/org/apache/commons/lang3/ArrayUtils.java | 18 +++++++++--------- src/main/java/org/apache/commons/lang3/Conversion.java | 2 +- .../java/org/apache/commons/lang3/text/StrBuilder.java | 6 +++--- .../org/apache/commons/lang3/time/FastDatePrinter.java | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/main/java/org/apache/commons/lang3/ArrayUtils.java b/src/main/java/org/apache/commons/lang3/ArrayUtils.java index ee1b215..dd9b5ca 100644 --- a/src/main/java/org/apache/commons/lang3/ArrayUtils.java +++ b/src/main/java/org/apache/commons/lang3/ArrayUtils.java @@ -6523,7 +6523,7 @@ public static int indexOf(final int[] array, final int valueToFind) { if (array == null) { return; } - int i = startIndexInclusive < 0 ? 0 : startIndexInclusive; + int i = Math.max(startIndexInclusive, 0); int j = Math.min(array.length, endIndexExclusive) - 1; boolean tmp; while (j > i) { @@ -6570,7 +6570,7 @@ public static int indexOf(final int[] array, final int valueToFind) { if (array == null) { return; } - int i = startIndexInclusive < 0 ? 0 : startIndexInclusive; + int i = Math.max(startIndexInclusive, 0); int j = Math.min(array.length, endIndexExclusive) - 1; byte tmp; while (j > i) { @@ -6617,7 +6617,7 @@ public static int indexOf(final int[] array, final int valueToFind) { if (array == null) { return; } - int i = startIndexInclusive < 0 ? 0 : startIndexInclusive; + int i = Math.max(startIndexInclusive, 0); int j = Math.min(array.length, endIndexExclusive) - 1; char tmp; while (j > i) { @@ -6664,7 +6664,7 @@ public static int indexOf(final int[] array, final int valueToFind) { if (array == null) { return; } - int i = startIndexInclusive < 0 ? 0 : startIndexInclusive; + int i = Math.max(startIndexInclusive, 0); int j = Math.min(array.length, endIndexExclusive) - 1; double tmp; while (j > i) { @@ -6711,7 +6711,7 @@ public static int indexOf(final int[] array, final int valueToFind) { if (array == null) { return; } - int i = startIndexInclusive < 0 ? 0 : startIndexInclusive; + int i = Math.max(startIndexInclusive, 0); int j = Math.min(array.length, endIndexExclusive) - 1; float tmp; while (j > i) { @@ -6758,7 +6758,7 @@ public static int indexOf(final int[] array, final int valueToFind) { if (array == null) { return; } - int i = startIndexInclusive < 0 ? 0 : startIndexInclusive; + int i = Math.max(startIndexInclusive, 0); int j = Math.min(array.length, endIndexExclusive) - 1; int tmp; while (j > i) { @@ -6805,7 +6805,7 @@ public static int indexOf(final int[] array, final int valueToFind) { if (array == null) { return; } - int i = startIndexInclusive < 0 ? 0 : startIndexInclusive; + int i = Math.max(startIndexInclusive, 0); int j = Math.min(array.length, endIndexExclusive) - 1; long tmp; while (j > i) { @@ -6856,7 +6856,7 @@ public static int indexOf(final int[] array, final int valueToFind) { if (array == null) { return; } - int i = startIndexInclusive < 0 ? 0 : startIndexInclusive; + int i = Math.max(startIndexInclusive, 0); int j = Math.min(array.length, endIndexExclusive) - 1; Object tmp; while (j > i) { @@ -6903,7 +6903,7 @@ public static int indexOf(final int[] array, final int valueToFind) { if (array == null) { return; } - int i = startIndexInclusive < 0 ? 0 : startIndexInclusive; + int i = Math.max(startIndexInclusive, 0); int j = Math.min(array.length, endIndexExclusive) - 1; short tmp; while (j > i) { diff --git a/src/main/java/org/apache/commons/lang3/Conversion.java b/src/main/java/org/apache/commons/lang3/Conversion.java index 18873d9..e710701 100644 --- a/src/main/java/org/apache/commons/lang3/Conversion.java +++ b/src/main/java/org/apache/commons/lang3/Conversion.java @@ -1534,7 +1534,7 @@ public class Conversion { if (nBytes > 16) { throw new IllegalArgumentException("nBytes is greater than 16"); } - longToByteArray(src.getMostSignificantBits(), 0, dst, dstPos, nBytes > 8 ? 8 : nBytes); + longToByteArray(src.getMostSignificantBits(), 0, dst, dstPos, Math.min(nBytes, 8)); if (nBytes >= 8) { longToByteArray(src.getLeastSignificantBits(), 0, dst, dstPos + 8, nBytes - 8); } diff --git a/src/main/java/org/apache/commons/lang3/text/StrBuilder.java b/src/main/java/org/apache/commons/lang3/text/StrBuilder.java index 21c88e4..0fabc10 100644 --- a/src/main/java/org/apache/commons/lang3/text/StrBuilder.java +++ b/src/main/java/org/apache/commons/lang3/text/StrBuilder.java @@ -2420,7 +2420,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build * @return the first index of the character, or -1 if not found */ public int indexOf(final char ch, int startIndex) { - startIndex = (startIndex < 0 ? 0 : startIndex); + startIndex = (Math.max(startIndex, 0)); if (startIndex >= size) { return -1; } @@ -2456,7 +2456,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build * @return the first index of the string, or -1 if not found */ public int indexOf(final String str, int startIndex) { - startIndex = (startIndex < 0 ? 0 : startIndex); + startIndex = (Math.max(startIndex, 0)); if (str == null || startIndex >= size) { return -1; } @@ -2511,7 +2511,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build * @return the first index matched, or -1 if not found */ public int indexOf(final StrMatcher matcher, int startIndex) { - startIndex = (startIndex < 0 ? 0 : startIndex); + startIndex = (Math.max(startIndex, 0)); if (matcher == null || startIndex >= size) { return -1; } diff --git a/src/main/java/org/apache/commons/lang3/time/FastDatePrinter.java b/src/main/java/org/apache/commons/lang3/time/FastDatePrinter.java index 888d3fb..48cd49b 100644 --- a/src/main/java/org/apache/commons/lang3/time/FastDatePrinter.java +++ b/src/main/java/org/apache/commons/lang3/time/FastDatePrinter.java @@ -214,7 +214,7 @@ public class FastDatePrinter implements DatePrinter, Serializable { if (tokenLen == 2) { rule = TwoDigitYearField.INSTANCE; } else { - rule = selectNumberRule(Calendar.YEAR, tokenLen < 4 ? 4 : tokenLen); + rule = selectNumberRule(Calendar.YEAR, Math.max(tokenLen, 4)); } if (c == 'Y') { rule = new WeekYear((NumberRule) rule);