mirror of
https://github.com/apache/commons-lang.git
synced 2025-02-13 05:25:20 +00:00
use_Math_max_min (#547)
This commit is contained in:
parent
34fcd18ae7
commit
9078cdc8c4
@ -6523,7 +6523,7 @@ public static void reverse(final boolean[] array, final int startIndexInclusive,
|
||||
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 void reverse(final byte[] array, final int startIndexInclusive, fi
|
||||
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 void reverse(final char[] array, final int startIndexInclusive, fi
|
||||
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 void reverse(final double[] array, final int startIndexInclusive,
|
||||
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 void reverse(final float[] array, final int startIndexInclusive, f
|
||||
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 void reverse(final int[] array, final int startIndexInclusive, fin
|
||||
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 void reverse(final long[] array, final int startIndexInclusive, fi
|
||||
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 void reverse(final Object[] array, final int startIndexInclusive,
|
||||
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 void reverse(final short[] array, final int startIndexInclusive, f
|
||||
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) {
|
||||
|
@ -1534,7 +1534,7 @@ public static byte[] uuidToByteArray(final UUID src, final byte[] dst, final int
|
||||
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);
|
||||
}
|
||||
|
@ -2420,7 +2420,7 @@ public int indexOf(final char ch) {
|
||||
* @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 int indexOf(final String str) {
|
||||
* @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 int indexOf(final StrMatcher matcher) {
|
||||
* @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;
|
||||
}
|
||||
|
@ -214,7 +214,7 @@ protected List<Rule> parsePattern() {
|
||||
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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user