Directly init refCnt to 1 (#8274)
Motivation: We should just directly init the refCnt to 1 and not use the AtomicIntegerFieldUpdater. Modifications: Just assing directly to 1. Result: Cleaner code and possible a bit faster as the JVM / JIT may be able to optimize the first store easily.
This commit is contained in:
parent
e542a2cf26
commit
c14efd952d
@ -31,7 +31,7 @@ public abstract class AbstractReferenceCountedByteBuf extends AbstractByteBuf {
|
||||
private static final AtomicIntegerFieldUpdater<AbstractReferenceCountedByteBuf> refCntUpdater =
|
||||
AtomicIntegerFieldUpdater.newUpdater(AbstractReferenceCountedByteBuf.class, "refCnt");
|
||||
|
||||
private volatile int refCnt;
|
||||
private volatile int refCnt = 1;
|
||||
|
||||
static {
|
||||
long refCntFieldOffset = -1;
|
||||
@ -49,7 +49,6 @@ public abstract class AbstractReferenceCountedByteBuf extends AbstractByteBuf {
|
||||
|
||||
protected AbstractReferenceCountedByteBuf(int maxCapacity) {
|
||||
super(maxCapacity);
|
||||
refCntUpdater.set(this, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user