This commit is contained in:
Gary Gregory 2020-04-20 16:58:26 -04:00
commit d8ebaf932d
1 changed files with 3 additions and 4 deletions

View File

@ -6421,9 +6421,8 @@ private static String replace(final String text, String searchString, final Stri
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 static String truncate(final String str, final int offset, final int maxW
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);