53 |
|
* @return the adder associated with the key |
54 |
|
*/ |
55 |
|
public LongAdder install(K key) { |
56 |
< |
LongAdder a = map.get(key); |
57 |
< |
if (a == null) { |
58 |
< |
LongAdder r = new LongAdder(); |
59 |
< |
if ((a = map.putIfAbsent(key, r)) == null) |
60 |
< |
a = r; |
61 |
< |
} |
62 |
< |
return a; |
56 |
> |
return map.computeIfAbsent(key, createAdder); |
57 |
|
} |
58 |
|
|
59 |
|
/** |
65 |
|
* @param x the value to add |
66 |
|
*/ |
67 |
|
public void add(K key, long x) { |
68 |
< |
LongAdder a = map.get(key); |
75 |
< |
if (a == null) |
76 |
< |
a = map.computeIfAbsent(key, createAdder); |
77 |
< |
a.add(x); |
68 |
> |
map.computeIfAbsent(key, createAdder).add(x); |
69 |
|
} |
70 |
|
|
71 |
|
/** |