On Wed, 5 Nov 2025 02:35:13 GMT, Jason Mehrens <[email protected]> wrote:

>> Thank you both!  @cl4es splitting it out had zero performance impact (per 
>> the benchmark).  As you said, it's a bit subjective... how strongly do you 
>> feel?  Other opinions are welcome too.
>
> I would think that you need to check `src.modCount` has same value at start 
> and end of the method.
> 
> 
> final int expectedSrcModCount = src.modCount;
> //access src internals....
> checkForComodification(expectedSrcModCount)
> 
> 
> Looks like ArrayList::toArray is not doing this check either.  So perhaps it 
> is not needed.  I would have thought mod check would have been needed in 
> toArray to mimic iterator behavior.  Therefore needed in addAll.

I'd have to see the code with the split methods to know for sure, but if it 
involves duplicating code, then I'd prefer to try harder to avoid the 
duplication. What's the main optimization here? Direct access to the argument 
ArrayList's array, avoiding an intermediate copy? If this is the case, then 
it's hard to believe that it's necessary to duplicate the remainder of the 
method, which does the growth and copying, which I think aren't changed by this 
optimization.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/28116#discussion_r2493058610

Reply via email to