[PATCH] Inefficient ArrayList.subList().toArray()

Claes Redestad claes.redestad at oracle.com
Fri Jan 26 13:31:31 UTC 2018

On 2018-01-26 07:20, Martin Buchholz wrote:
> It's still possible to find simple performance improvements in classes like
> ArrayList.


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...


More information about the core-libs-dev mailing list