On Mon, Apr 15, 2013 at 11:31 AM, Martin Buchholz <marti...@google.com>wrote:

>
> 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).
>

 Proceeding further along this train of thought, I might start with
AbstractCollection.toString() (and similar methods) and attempt to make it
maximally efficient.
Maybe add a method to JavaLangAccess to make a String directly from a
perfectly sized array (as needed elsewhere?).  Maybe create a
StringBuilder-like class that works better for typical use cases?

Software is hard.

Reply via email to