It is natural to compare StringJoiner with guava Joiner.
http://docs.guava-libraries.googlecode.com/git/javadoc/com/google/common/base/Joiner.html
Joiner is popular and has stood the test of time.

Joiner designers chose not to include a prefix and suffix, presumably
because that is an independent concern - it's not a "joining" activity.

OTOH, I'm guessing you are trying to improve the performance of operations
like List.toString.
More efficient (single copy char[]) would be to collect all the
sub-CharSequences in a CharSequence[],  pre-compute the final length of the
char[], allocate an array of exactly the required length, and create the
final string directly from that using the package-private constructor (but
in the unlikely event that a subsequence changed in size while concat'ing,
be prepared to resize the array).




On Thu, Apr 11, 2013 at 3:33 PM, Jim Gish <jim.g...@oracle.com> wrote:

> Please review http://cr.openjdk.java.net/~**jgish/Bugs-5015163-7175206-**
> 7172553/ <http://cr.openjdk.java.net/~jgish/Bugs-5015163-7175206-7172553/><
> http://cr.openjdk.java.net/%**7Ejgish/Bugs-5015163-7175206-**7172553/<http://cr.openjdk.java.net/%7Ejgish/Bugs-5015163-7175206-7172553/>
> >
>
> These are changes that we made in lambda that we're now bringing into JDK8.
>
> I've made a couple of additions - making StringJoiner final and adding a
> couple of constructors to set the emptyOutput chars.
>
> Thanks,
>    Jim
>
> --
> Jim Gish | Consulting Member of Technical Staff | +1.781.442.0304
> Oracle Java Platform Group | Core Libraries Team
> 35 Network Drive
> Burlington, MA 01803
> jim.g...@oracle.com
>
>

Reply via email to