public long rawCopy(@NotNull RandomDataInput bytes, long offset, long length) throws BufferOverflowException, BufferUnderflowException { long len = Math.min(writeRemaining(), Math.min(bytes.capacity() - offset, length)); if (len > 0) { writeCheckOffset(writePosition(), len); OS.memory().copyMemory(bytes.addressForRead(offset), addressForWrite(writePosition()), len); writeSkip(len); } return len; }
.append(", rlim: ").append(readLimit) .append(", wlim: ").append(asSize(bytes.writeLimit())) .append(", cap: ").append(asSize(bytes.capacity())) .append(" ] "); try {
protected void optimisedWrite(@NotNull RandomDataInput bytes, long offset, long length) { if (length <= safeCopySize() && isDirectMemory() && bytes.isDirectMemory()) { long len = Math.min(writeRemaining(), Math.min(bytes.capacity() - offset, length)); if (len > 0) { long address = bytes.addressForRead(offset); long address2 = addressForWrite(writePosition()); assert address != 0; assert address2 != 0; writeCheckOffset(writePosition(), len); OS.memory().copyMemory(address, address2, len); writeSkip(len); } } else { super.write(bytes, offset, length); } }