RFR: 8196340: (coll) Examine overriding inherited methods in ArrayList and ArrayList.SubList
Martin Buchholz
martinrb at google.com
Mon May 14 15:46:05 UTC 2018
On Mon, May 14, 2018 at 7:33 AM, Claes Redestad <claes.redestad at oracle.com>
wrote:
>
>> I would prefer having only one comodification check for a bulk operation,
>> but I understand that checking at each step is more compatible with the
>> default implementation.
>>
>> 594 for (int i = 0; i < s; i++) {
>> 595 if (!Objects.equals(es[i], otherEs[i])) {
>> 596 other.checkForComodification(otherModCount);
>> 597 checkForComodification(expectedModCount);
>> 598 return false;
>> 599 }
>> 600 }
>>
>>
> Perhaps you misread as I think the patch does what I think you're
> suggesting and only checks once. True, this is subtly
> different in behavior from the current implementation
> which is fail-fast.
>
Oh right, I did miss that. I would probably micro-refactor that into
boolean result = true;
...
+ other.checkForComodification(otherModCount);
+ checkForComodification(expectedModCount);
+ return result;
if only to save bytecode.
> While it shouldn't matter semantically, it could in theory mean a
> measurable delay in throwing a CME when dealing
> with large lists. As CMEs in ArrayLists could be considered a coding
> error - and the speedup of only checking once
> for a bulk operation like equal is significant - I think it's a reasonable
> trade-off to go ahead with this.
Completely agree.
More information about the core-libs-dev
mailing list