On Fri, 7 Apr 2023 08:27:18 GMT, Tingjun Yuan <d...@openjdk.org> wrote:

> In the current implementation of `String.join(CharSequence, Iterable)`, the 
> temp array `elems` is always initialized with a length of 8. It will cause 
> many array recreations when the `Iterable` contains more than 8 elements. 
> Furthermore, it's very common that an `Iterable` is also a `Collection`. So 
> if the `Iterable` is an instance of `Collection`, the initial length of the 
> array can be `((Collection<?>)elements).size()`. It will not change the 
> current behavior even if the `Collection` is modified asynchronously.
> 
> I don't know whether this change requires a CSR request.

It would be good to show the performance improvement via a few jmh runs.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/13383#issuecomment-1500986773

Reply via email to