On Sun, 9 Apr 2023 02:37:45 GMT, Tingjun Yuan <d...@openjdk.org> wrote:

>> This appears to be a 4% improvement for non-concurrent structures like 
>> ArrayList or LinkedHashSet, if we ignore the baseline difference (for 
>> Iterable). This is anticipated as the growth of array size is exponential, 
>> so the total allocation is effectively O(N log(N)). Can you try with smaller 
>> quantities, like single-digit or double digits length, which may be more 
>> frequent in application?
>
> @liach Working on that.

> @yuantj Alternatively, you can probably try working on the `toArray` result 
> of a collection than to allocate a new String array. This might be more 
> efficient for some implementations like ArrayList as well, in addition to 
> benefiting concurrent collections.

The method accepts collections of nullable CharSequences, which may not be 
Strings. So `c.toArray(new String[0])` doesn't work.

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

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

Reply via email to