code: private static ByteBuffer[] nioBuffers(ByteBuf buf, ByteBuffer[] singleBuffer) {
      // As CompositeByteBuf.nioBufferCount() can be expensive (as it needs to check all composed
      // ByteBuf to calculate the count) we will just assume a CompositeByteBuf contains more than 1
      // ByteBuf. The worst that can happen is that we allocate an extra ByteBuffer[] in
      // CompositeByteBuf.nioBuffers() which is better than walking the composed ByteBuf in most
      // cases.
      if (!(buf instanceof CompositeByteBuf) && buf.nioBufferCount() == 1) {
        // We know its only backed by 1 ByteBuffer so use internalNioBuffer to keep object
        // allocation to a minimum.
        singleBuffer[0] = buf.internalNioBuffer(buf.readerIndex(), buf.readableBytes());
        return singleBuffer;
      }
  
      return buf.nioBuffers();
    }
docs: Optimized accessor for obtaining the underlying NIO buffers for a Netty {@link ByteBuf}. Based
  on code from Netty's {@code SslHandler}. This method returns NIO buffers that span the readable
  region of the {@link ByteBuf}.