Resync j.u.c and Update ConcurrentHashMap to v8 - JEP 155

Martin Buchholz martinrb at google.com
Tue May 28 21:26:19 UTC 2013


On Fri, May 24, 2013 at 8:17 PM, Mike Duigou <mike.duigou at oracle.com> wrote:

>
> - It was surprising (and somewhat disappointing) to see changes like the
> following in various places. Is iterator creation that expensive? I'd hate
> to have to go back to using old style for loops everywhere.
>
> -        List<Future<T>> futures = new ArrayList<Future<T>>(tasks.size());
> +        ArrayList<Future<T>> futures = new
> ArrayList<Future<T>>(tasks.size());
>
> Why not 'List<Future<T>> futures = new ArrayList<>(tasks.size());' ?
>
> and
>
> -                for (Future<T> f : futures)
> -                    f.cancel(true);
> +                for (int i = 0, size = futures.size(); i < size; i++)
> +                    futures.get(i).cancel(true);
>
> Use forEach(f -> { f.cancel(true);}) ?
>

I don't think we want to use higher-level constructs in the implementation
of core libraries until all the popular VM implementations make the
overhead unmeasurably small, which is unlikely to happen - at least here,
where the cost is only a few bytes, not lines, of code.  Elsewhere, I am
also on the side of trying to persuade Doug to write slightly less extreme
code.



More information about the core-libs-dev mailing list