Simplify some usages of the ternary operator with calls to Math.max() and Math.min(). (#512)
This commit is contained in:
parent
271cf4c9e9
commit
44d4acc621
|
@ -6421,9 +6421,8 @@ public class StringUtils {
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
final int replLength = searchString.length();
|
final int replLength = searchString.length();
|
||||||
int increase = replacement.length() - replLength;
|
int increase = Math.max(replacement.length() - replLength, 0);
|
||||||
increase = increase < 0 ? 0 : increase;
|
increase *= max < 0 ? 16 : Math.min(max, 64);
|
||||||
increase *= max < 0 ? 16 : max > 64 ? 64 : max;
|
|
||||||
final StringBuilder buf = new StringBuilder(text.length() + increase);
|
final StringBuilder buf = new StringBuilder(text.length() + increase);
|
||||||
while (end != INDEX_NOT_FOUND) {
|
while (end != INDEX_NOT_FOUND) {
|
||||||
buf.append(text, start, end).append(replacement);
|
buf.append(text, start, end).append(replacement);
|
||||||
|
@ -9168,7 +9167,7 @@ public class StringUtils {
|
||||||
return EMPTY;
|
return EMPTY;
|
||||||
}
|
}
|
||||||
if (str.length() > maxWidth) {
|
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, ix);
|
||||||
}
|
}
|
||||||
return str.substring(offset);
|
return str.substring(offset);
|
||||||
|
|
Loading…
Reference in New Issue