提交 69ea2e49 authored 作者: noelgrandin@gmail.com's avatar noelgrandin@gmail.com

avoid unnecessary store operation

上级 6c89887a
......@@ -89,11 +89,11 @@ public final class ImmutableArray2<K> implements Iterable<K> {
boolean extendable;
if (index == len - 1) {
AtomicBoolean x = canExtend;
// can set it to null early - we anyway
// reset the flag, so it is no longer useful
canExtend = null;
if (array.length > index && x != null) {
if (x.getAndSet(false)) {
if (x != null) {
// can set it to null early - we anyway
// reset the flag, so it is no longer useful
canExtend = null;
if (array.length > index && x.getAndSet(false)) {
array[index] = obj;
return new ImmutableArray2<K>(array, len, true);
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论