@Override public ByteBuf copy(int index, int length) { checkIndex(index, length); PooledUnsafeDirectByteBuf copy = (PooledUnsafeDirectByteBuf) alloc().directBuffer(length, maxCapacity()); if (length != 0) { PlatformDependent.copyMemory(addr(index), copy.addr(0), length); copy.setIndex(0, length); } return copy; }
static PooledUnsafeDirectByteBuf newInstance(int maxCapacity) { PooledUnsafeDirectByteBuf buf = RECYCLER.get(); buf.setRefCnt(1); buf.maxCapacity(maxCapacity); return buf; }