use_Math_max_min (#547)

This commit is contained in:
XenoAmess 2020-06-13 22:49:59 +08:00 committed by GitHub
parent 34fcd18ae7
commit 9078cdc8c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 14 deletions

View File

@ -6523,7 +6523,7 @@ public static int indexOf(final int[] array, final int valueToFind) {
if (array == null) { if (array == null) {
return; return;
} }
int i = startIndexInclusive < 0 ? 0 : startIndexInclusive; int i = Math.max(startIndexInclusive, 0);
int j = Math.min(array.length, endIndexExclusive) - 1; int j = Math.min(array.length, endIndexExclusive) - 1;
boolean tmp; boolean tmp;
while (j > i) { while (j > i) {
@ -6570,7 +6570,7 @@ public static int indexOf(final int[] array, final int valueToFind) {
if (array == null) { if (array == null) {
return; return;
} }
int i = startIndexInclusive < 0 ? 0 : startIndexInclusive; int i = Math.max(startIndexInclusive, 0);
int j = Math.min(array.length, endIndexExclusive) - 1; int j = Math.min(array.length, endIndexExclusive) - 1;
byte tmp; byte tmp;
while (j > i) { while (j > i) {
@ -6617,7 +6617,7 @@ public static int indexOf(final int[] array, final int valueToFind) {
if (array == null) { if (array == null) {
return; return;
} }
int i = startIndexInclusive < 0 ? 0 : startIndexInclusive; int i = Math.max(startIndexInclusive, 0);
int j = Math.min(array.length, endIndexExclusive) - 1; int j = Math.min(array.length, endIndexExclusive) - 1;
char tmp; char tmp;
while (j > i) { while (j > i) {
@ -6664,7 +6664,7 @@ public static int indexOf(final int[] array, final int valueToFind) {
if (array == null) { if (array == null) {
return; return;
} }
int i = startIndexInclusive < 0 ? 0 : startIndexInclusive; int i = Math.max(startIndexInclusive, 0);
int j = Math.min(array.length, endIndexExclusive) - 1; int j = Math.min(array.length, endIndexExclusive) - 1;
double tmp; double tmp;
while (j > i) { while (j > i) {
@ -6711,7 +6711,7 @@ public static int indexOf(final int[] array, final int valueToFind) {
if (array == null) { if (array == null) {
return; return;
} }
int i = startIndexInclusive < 0 ? 0 : startIndexInclusive; int i = Math.max(startIndexInclusive, 0);
int j = Math.min(array.length, endIndexExclusive) - 1; int j = Math.min(array.length, endIndexExclusive) - 1;
float tmp; float tmp;
while (j > i) { while (j > i) {
@ -6758,7 +6758,7 @@ public static int indexOf(final int[] array, final int valueToFind) {
if (array == null) { if (array == null) {
return; return;
} }
int i = startIndexInclusive < 0 ? 0 : startIndexInclusive; int i = Math.max(startIndexInclusive, 0);
int j = Math.min(array.length, endIndexExclusive) - 1; int j = Math.min(array.length, endIndexExclusive) - 1;
int tmp; int tmp;
while (j > i) { while (j > i) {
@ -6805,7 +6805,7 @@ public static int indexOf(final int[] array, final int valueToFind) {
if (array == null) { if (array == null) {
return; return;
} }
int i = startIndexInclusive < 0 ? 0 : startIndexInclusive; int i = Math.max(startIndexInclusive, 0);
int j = Math.min(array.length, endIndexExclusive) - 1; int j = Math.min(array.length, endIndexExclusive) - 1;
long tmp; long tmp;
while (j > i) { while (j > i) {
@ -6856,7 +6856,7 @@ public static int indexOf(final int[] array, final int valueToFind) {
if (array == null) { if (array == null) {
return; return;
} }
int i = startIndexInclusive < 0 ? 0 : startIndexInclusive; int i = Math.max(startIndexInclusive, 0);
int j = Math.min(array.length, endIndexExclusive) - 1; int j = Math.min(array.length, endIndexExclusive) - 1;
Object tmp; Object tmp;
while (j > i) { while (j > i) {
@ -6903,7 +6903,7 @@ public static int indexOf(final int[] array, final int valueToFind) {
if (array == null) { if (array == null) {
return; return;
} }
int i = startIndexInclusive < 0 ? 0 : startIndexInclusive; int i = Math.max(startIndexInclusive, 0);
int j = Math.min(array.length, endIndexExclusive) - 1; int j = Math.min(array.length, endIndexExclusive) - 1;
short tmp; short tmp;
while (j > i) { while (j > i) {

View File

@ -1534,7 +1534,7 @@ public class Conversion {
if (nBytes > 16) { if (nBytes > 16) {
throw new IllegalArgumentException("nBytes is greater than 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) { if (nBytes >= 8) {
longToByteArray(src.getLeastSignificantBits(), 0, dst, dstPos + 8, nBytes - 8); longToByteArray(src.getLeastSignificantBits(), 0, dst, dstPos + 8, nBytes - 8);
} }

View File

@ -2420,7 +2420,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
* @return the first index of the character, or -1 if not found * @return the first index of the character, or -1 if not found
*/ */
public int indexOf(final char ch, int startIndex) { public int indexOf(final char ch, int startIndex) {
startIndex = (startIndex < 0 ? 0 : startIndex); startIndex = (Math.max(startIndex, 0));
if (startIndex >= size) { if (startIndex >= size) {
return -1; 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 * @return the first index of the string, or -1 if not found
*/ */
public int indexOf(final String str, int startIndex) { public int indexOf(final String str, int startIndex) {
startIndex = (startIndex < 0 ? 0 : startIndex); startIndex = (Math.max(startIndex, 0));
if (str == null || startIndex >= size) { if (str == null || startIndex >= size) {
return -1; return -1;
} }
@ -2511,7 +2511,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
* @return the first index matched, or -1 if not found * @return the first index matched, or -1 if not found
*/ */
public int indexOf(final StrMatcher matcher, int startIndex) { public int indexOf(final StrMatcher matcher, int startIndex) {
startIndex = (startIndex < 0 ? 0 : startIndex); startIndex = (Math.max(startIndex, 0));
if (matcher == null || startIndex >= size) { if (matcher == null || startIndex >= size) {
return -1; return -1;
} }

View File

@ -214,7 +214,7 @@ public class FastDatePrinter implements DatePrinter, Serializable {
if (tokenLen == 2) { if (tokenLen == 2) {
rule = TwoDigitYearField.INSTANCE; rule = TwoDigitYearField.INSTANCE;
} else { } else {
rule = selectNumberRule(Calendar.YEAR, tokenLen < 4 ? 4 : tokenLen); rule = selectNumberRule(Calendar.YEAR, Math.max(tokenLen, 4));
} }
if (c == 'Y') { if (c == 'Y') {
rule = new WeekYear((NumberRule) rule); rule = new WeekYear((NumberRule) rule);