RFR [S] 8077242: (str) Optimize AbstractStringBuilder.append(CharSequence, int, int) for String argument
Martin Buchholz
martinrb at google.com
Tue Jun 30 21:59:29 UTC 2015
This looks good.
Because we already have append(String) it *may* be a good idea to add
append(String, int, int).
See also my failure to add getChars to CharSequence itself. If we (you?)
could make that happen, that would eliminate the need for instanceof String
etc.
On Sat, Jun 27, 2015 at 7:23 AM, Ivan Gerasimov <ivan.gerasimov at oracle.com>
wrote:
> Hello!
>
> AbstractStringBuilder, which is base for StringBuilder and StringBuffer
> has a method for appending a sub-sequence of a CharSequence.
> Internally, it copies one char at a time in a loop, picking them up with
> CharSequence.charAt() method.
> For the case when the argument is a String, it can be done more
> efficiently, by a call to String.getChars().
> Since String is a final class, it should be safe to pass 'value' to its
> method.
>
> I've also found a few places in JDK where code can be done more efficient,
> using this optimization.
>
> Would you please help review this fix?
>
> BUGURL: https://bugs.openjdk.java.net/browse/JDK-8077242
> WEBREV: http://cr.openjdk.java.net/~igerasim/8077242/02/webrev/
>
> Sincerely yours,
> Ivan
>
More information about the core-libs-dev
mailing list