[PATCH] Inefficient ArrayList.subList().toArray()
Martin Buchholz
martinrb at google.com
Fri Jan 26 17:12:43 UTC 2018
It may be that array-backed lists inheriting from AbstractList is not
useful except when creating a prototype (or as a way of testing
AbstractList!) because a high-quality implementation should always override.
On Fri, Jan 26, 2018 at 5:31 AM, Claes Redestad <claes.redestad at oracle.com>
wrote:
> On 2018-01-26 07:20, Martin Buchholz wrote:
>
>> It's still possible to find simple performance improvements in classes
>> like
>> ArrayList.
>>
>
> Indeed!
>
> It seems ArrayList.SubList delegates quite a few of its implementations
> to AbstractList and AbstractCollection, which uses iterators for things
> that could be done more efficiently with conventional for-loops.
>
> This includes contains, equals, hashCode, indexOf, lastIndexOf... I saw
> up to 7x improvements on some of these over the inherited
> implementations when providing specialized ones for ImmutableList.SubList
> as part of JDK-8193128
>
> I'll file a bug and maybe even tinker with it when I find some time...
>
> /Claes
>
More information about the core-libs-dev
mailing list