[PATCH] Implement a noop clear() for Collections#EMPTY_LIST
Louis Wasserman
lowasser at google.com
Sat May 28 17:02:07 UTC 2016
Is it? IIRC EmptyMap and EmptySet will use a singleton unmodifiable empty
Iterator, so they won't incur any allocation, and the clear() will finish
immediately with no work anyway.
On Sat, May 28, 2016, 2:05 AM Mohamed Naufal <naufal11 at gmail.com> wrote:
> Hi,
>
> I see that this is applicable to EmptyMap and EmptySet as well, here's an
> updated patch with clear() overridden for all 3 classes.
>
> Thanks,
> Naufal
>
> On 23 May 2016 at 16:13, Paul Sandoz <paul.sandoz at oracle.com> wrote:
>
> > Hi Naufal,
> >
> > Thanks for looking at this.
> >
> > For us to accept your patch (no matter how small) you need to become a
> > contributor, which requires that you agree to the Oracle Contributor
> > Agreement (OCA), see:
> >
> > http://openjdk.java.net/contribute/
> >
> > Thanks,
> > Paul.
> >
> > > On 22 May 2016, at 12:10, Mohamed Naufal <naufal11 at gmail.com> wrote:
> > >
> > > Hi,
> > >
> > > A call to clear() on Collections#EMPTY_LIST is currently redirected to
> > > AbstractList#clear(), which performs a bunch of checks and creates a
> > > ListItr object, all of which is unnecessary for an EmptyList.
> > >
> > > PFA a patch that implements a noop clear() for EmptyList.
> > >
> > > Thanks,
> > > Naufal
> > > <EmptyList_clear.diff>
> >
> >
>
More information about the core-libs-dev
mailing list