RFR: 8005051: default methods for Iterator
forax at univ-mlv.fr
Fri Dec 14 13:19:02 UTC 2012
On 12/14/2012 02:00 PM, Paul Sandoz wrote:
> On Dec 14, 2012, at 11:54 AM, Remi Forax <forax at univ-mlv.fr> wrote:
>> We can't remove Collection.forEach without having perf issue because the stream pipeline use it.
>> Iterator.forEach can be removed but it's a pity because it's really convenient,
> And a case can be made performance wise too (there are optimal implementations in the stream code base).
> I have found that forEach, in general, has been very useful. Since it abstracts away the details of traversal it has enabled better re-use of code.
The VM profiles the iterator when calling hasNext and next, if you end
up by using Iterator.forEach instead of one of its overriden methods,
you share the profile between part of the pipeline that should not be
shared. So using Iterator.forEach may be less performant or not
depending if forEach is overriden by a specific implementation or not.
>> a possble solution is to rename Iterator.forEach() to something else.
>>> Please review
More information about the core-libs-dev