RFR: 8155600 - Performance optimization of Arrays.asList().iterator()

Tagir F. Valeev amaembo at gmail.com
Fri Apr 29 12:40:41 UTC 2016

Thank you for reviews! Here's updated webrev:


AS>  *) Does EA break if you make ArrayItr inner class to gain the access to
AS> E[] a?

No, I checked, it still allocates.

AS>  *) next(): Missing braces in throw new NSEE() block;


AS>  *) next(): Why loading this.a into local?

Removed local a. Seems that this change does not affect the

AS> I agree with Aleksey but I'd go as far as to say that not only
AS> this.a is unnecessary, but i as well. The body of next() looks too
AS> elaborate. This seems equivalent and concise:

AS>   if (cursor >= a.length) {
AS>       throw new NoSuchElementException();
AS>   }
AS>   return a[cursor++];

I tried to mimic java.util.ArrayList.iterator() implementation. Here I
would agree with Peter Levart and leave local variable.

AS> I think Arrays.asList is frequently used in tests already. But, a quick
AS> boundary jtreg test would be nice to have, given now we have a special
AS> iterator.

Simple test is implemented. I did not find proper class to put it, so
I created new class instead (test/java/util/Arrays/AsList.java).
Please check.

With best regards,
Tagir Valeev.

More information about the core-libs-dev mailing list