RFR 8037106: Optimize Arrays.asList(...).forEach (original) (raw)
Martin Buchholz martinrb at google.com
Mon Mar 17 19:13:09 UTC 2014
- Previous message: RFR 8037106: Optimize Arrays.asList(...).forEach
- Next message: RFR 8037106: Optimize Arrays.asList(...).forEach
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Mon, Mar 17, 2014 at 11:36 AM, Ulf Zibis <Ulf.Zibis at cosoco.de> wrote:
Am 14.03.2014 16:46, schrieb Martin Buchholz: + final int size = a.length; + for (int i = 0; i < size; i++) {
I like to write this using the idiom for (int i = 0, size = ...; i < size; i++) This is not thread-proof (Given there is no: final E[] a = this.a;). If a becomes replaced concurrently while looping, size becomes invalid as length of a.
That's orthogonal, I think.
Certainly, the reflex in concurrent code is to always copy fields to locals, for both performance and correctness.
- Previous message: RFR 8037106: Optimize Arrays.asList(...).forEach
- Next message: RFR 8037106: Optimize Arrays.asList(...).forEach
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]