In most cases we are seeing a `PooledHeapByteBuf` here now. No need to redundantly create an new `ByteBuffer` and single element array for it here when we can just directly unwrap its internal `byte[]`.
This commit is contained in:
parent
de7dd6154e
commit
cac85a6f18
|
@ -109,6 +109,8 @@ public class Netty4Utils {
|
|||
final int readableBytes = buffer.readableBytes();
|
||||
if (readableBytes == 0) {
|
||||
return BytesArray.EMPTY;
|
||||
} else if (buffer.hasArray()) {
|
||||
return new BytesArray(buffer.array(), buffer.arrayOffset() + buffer.readerIndex(), readableBytes);
|
||||
} else {
|
||||
final ByteBuffer[] byteBuffers = buffer.nioBuffers();
|
||||
return BytesReference.fromByteBuffers(byteBuffers);
|
||||
|
|
|
@ -66,6 +66,8 @@ class ByteBufUtils {
|
|||
final int readableBytes = buffer.readableBytes();
|
||||
if (readableBytes == 0) {
|
||||
return BytesArray.EMPTY;
|
||||
} else if (buffer.hasArray()) {
|
||||
return new BytesArray(buffer.array(), buffer.arrayOffset() + buffer.readerIndex(), readableBytes);
|
||||
} else {
|
||||
final ByteBuffer[] byteBuffers = buffer.nioBuffers();
|
||||
return BytesReference.fromByteBuffers(byteBuffers);
|
||||
|
|
Loading…
Reference in New Issue