RFR: 8051057: (s) Optimize StringCharBuffer.toString(int, int)
mike.duigou at oracle.com
Thu Jul 17 22:05:46 UTC 2014
While investigating another issue I ran across some code in java.nio.StringCharBuffer.toString(int, int) which might be possible to improve. Currently the implementation calls toString() on the source CharSequence and then uses String.substring to create the desired range. For the current String, StringBuilder and StringBuffer implementations it would be more efficient to first generate the subSequence via CharSequence.subSequence(int, int) and then call toString() on the sub-sequence. For these classes the toString() is actually a NOP as their CharSequence.subSequence(int, int) implementations return a String instance.
I looked for other CharSequence implementations and couldn't find any which would preform better with current StringCharBuffer.toString(int, int) implementation.
Does this seem like a worthwhile improvement for all of the important CharSequence implementations?
More information about the core-libs-dev