RFR 8170348: Appendable.appendN(char, int) method to append multiple copies of char
ivan.gerasimov at oracle.com
Sun Dec 11 21:03:02 UTC 2016
Thank you Peter for the suggestion!
> An alternative to a new virtual method on Appendable (or maybe a
> complement to it) could be a special internal CharSequence
> implementation (CharRepetitions) with a static factory method on
> CharSequence like the following:
I think it's a clever idea!
Though it might be harder to implement the special optimized handling of
such sequences by Appendable implementations outside java.lang.
> Together with special-case optimization in
> AbstractStringBuilder.append(CharSequence) it can perform equally well
> when JITed. I took your benchmark and modified it a bit:
> ...I moved sb.setLength(0) into a special @Setup method so that it
> doesn't cause the remaining tested code to be over-optimized. You can
> try just this change in your benchmark and you'll notice a difference.
Actually, in the benchmark I tried to follow the suggestions found here:
Note, how the Level.Invocation setup is avoided in the measureRight
With kind regards,
More information about the core-libs-dev