[jOOQ/jOOQ#8803] Improve performance of StringUtils#replace()

Replace `buf.append(text.substring(start, end))` with `buf.append(text,
start, end)` in `StringUtils#replace()`.
This commit is contained in:
Knut Wannheden 2019-06-18 07:48:24 +02:00
parent 5b26bd463d
commit 8ceaf4ebf1

View File

@ -780,14 +780,14 @@ public final class StringUtils {
increase *= (max < 0 ? 16 : (max > 64 ? 64 : max));
StringBuilder buf = new StringBuilder(text.length() + increase);
while (end != INDEX_NOT_FOUND) {
buf.append(text.substring(start, end)).append(replacement);
buf.append(text, start, end).append(replacement);
start = end + replLength;
if (--max == 0) {
break;
}
end = text.indexOf(searchString, start);
}
buf.append(text.substring(start));
buf.append(text, start, text.length());
return buf.toString();
}