use StringBuilder#append(CharSequence, int, int) were possible to improve performance
(similar to LANG-1358, thanks to Stephane Landelle for the suggestion)
This commit is contained in:
parent
04ca0852b9
commit
713c77ceda
|
@ -387,11 +387,10 @@ public void appendToString(final StringBuffer buffer, final String toString) {
|
|||
final int pos1 = toString.indexOf(contentStart) + contentStart.length();
|
||||
final int pos2 = toString.lastIndexOf(contentEnd);
|
||||
if (pos1 != pos2 && pos1 >= 0 && pos2 >= 0) {
|
||||
final String data = toString.substring(pos1, pos2);
|
||||
if (fieldSeparatorAtStart) {
|
||||
removeLastFieldSeparator(buffer);
|
||||
}
|
||||
buffer.append(data);
|
||||
buffer.append(toString, pos1, pos2);
|
||||
appendFieldSeparator(buffer);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -308,7 +308,7 @@ public static String wrap(final String str, int wrapLength, String newLineStr, f
|
|||
|
||||
if (spaceToWrapAt >= offset) {
|
||||
// normal case
|
||||
wrappedLine.append(str.substring(offset, spaceToWrapAt));
|
||||
wrappedLine.append(str, offset, spaceToWrapAt);
|
||||
wrappedLine.append(newLineStr);
|
||||
offset = spaceToWrapAt + 1;
|
||||
|
||||
|
@ -316,7 +316,7 @@ public static String wrap(final String str, int wrapLength, String newLineStr, f
|
|||
// really long word or URL
|
||||
if (wrapLongWords) {
|
||||
// wrap really long word one line at a time
|
||||
wrappedLine.append(str.substring(offset, wrapLength + offset));
|
||||
wrappedLine.append(str, offset, wrapLength + offset);
|
||||
wrappedLine.append(newLineStr);
|
||||
offset += wrapLength;
|
||||
} else {
|
||||
|
@ -327,11 +327,11 @@ public static String wrap(final String str, int wrapLength, String newLineStr, f
|
|||
}
|
||||
|
||||
if (spaceToWrapAt >= 0) {
|
||||
wrappedLine.append(str.substring(offset, spaceToWrapAt));
|
||||
wrappedLine.append(str, offset, spaceToWrapAt);
|
||||
wrappedLine.append(newLineStr);
|
||||
offset = spaceToWrapAt + 1;
|
||||
} else {
|
||||
wrappedLine.append(str.substring(offset));
|
||||
wrappedLine.append(str, offset, str.length());
|
||||
offset = inputLineLength;
|
||||
}
|
||||
}
|
||||
|
@ -339,7 +339,7 @@ public static String wrap(final String str, int wrapLength, String newLineStr, f
|
|||
}
|
||||
|
||||
// Whatever is left in line is short enough to just pass through
|
||||
wrappedLine.append(str.substring(offset));
|
||||
wrappedLine.append(str, offset, str.length());
|
||||
|
||||
return wrappedLine.toString();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue