[10?] RFR: 8193128: Reduce number of implementation classes returned by List/Set/Map.of() (original) (raw)

Claes Redestad claes.redestad at oracle.com
Fri Dec 8 15:13:06 UTC 2017


Hi,

On 2017-12-08 07:54, Andrej Golovnin wrote:

Hi Claes,

http://cr.openjdk.java.net/~redestad/8193128/open.02/ I think you should provide specialised implementations of the #indexOf() and #lastIndexOf() methods in the classes List12 and ListN. Using an iterator in List12 is an overkill. But even in ListN using a simple for loop would be much better.

it's somewhat ironic that I started looking at this because indexOf was slow due use of iterators[1], but then never got around to specialize them in this patch.

In any case please take look at the implementation of the #lastIndexOf() method in the AbstractImmutableList class. It looks like a copy of AbstractImmutableList#indexOf() and this is wrong.

Nice catch! Quite the embarrassing copy-paste that...

http://cr.openjdk.java.net/~redestad/8193128/open.03/

Thanks!

/Claes

[1] https://bugs.openjdk.java.net/browse/JDK-8191442



More information about the core-libs-dev mailing list