RFR 8005311: Add Scalable Updatable Variables, DoubleAccumulator, DoubleAdder, LongAccumulator, LongAdder
Martin Buchholz
martinrb at google.com
Sun Jan 6 20:25:15 UTC 2013
On Sat, Jan 5, 2013 at 3:42 PM, Remi Forax <forax at univ-mlv.fr> wrote:
>
> The code is not very java-ish,
>
Yes, j.u.c.-java is hard to read due to extreme performance orientation and
need to save reads in locals everywhere, and pretty far from java
programmer mainstream.
I'm also looking at LongAccumulator.accumulate(long).
- shouldn't "function" also be pulled into a local?
- Why "as"? Why not "cs"? Did Cell once have a name beginning with "A"?
- (m = as.length - 1) < 0 ?? as.length should always be >= 2, so this
check should be redundant. Or is this to help hotspot elide NPE throw code?
- We're checking as for null twice, which bugs me a bit.
- Why not push most of this method into Striped64, as in
Striped64: void accumulateLong(long x, LongBinaryOperator fn)
LongAccumulator: void accumulate(long x) { return accumulateLong(x,
function); }
---
I still like this style for pulling final fields into locals (but others
don't seem to share my taste):
final Cell[] cells = this.cells;
final LongBinaryOperator function = this.function;
More information about the core-libs-dev
mailing list