RFR: 8077242: Add default method CharSequence.getChars(int srcBegin, int srcEnd, char dst, int dstBegin)
ivan.gerasimov at oracle.com
Sat May 9 16:03:43 UTC 2015
The String class has getChars(int srcBegin, int srcEnd, char dst, int
dstBegin) which is used to efficiently extract substrings, avoiding
The AbstractStringBuilder has the method with the same signature.
I propose to add a default implementation of this method to the
It can used, for example, in AbstractStringBuilder.append(CharSequence
s, int start, int end) instead of the for-loop.
This, in turn, allows to simplify
In the webrev, I also included a few optimizations of the kind:
stringBuilder.append(string.substring(from, to)) =>
stringBuilder.append(string, from, to).
The later variant becomes more effective after the proposed fix.
If people agree that this change is useful, I'll file a CCC request.
More information about the core-libs-dev