Skip to content

Commit 2f08f0d

Browse files
committed
Set max capacity for remaining buf
This allows the returned buffer to be a cached empty buf if the original buffer was already fully read
1 parent d3f92ce commit 2f08f0d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

common/src/main/java/com/viaversion/viaversion/connection/UserConnectionImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ private void writeToBuffer(final PacketWrapperImpl wrapper, final ByteBuf buf, f
373373

374374
// Instead of allocating a possible unnecessarily large buffer to write the wrapper contents to,
375375
// only allocate the remaining bytes and write the rest to the original buf's head directly.
376-
final ByteBuf remainingBuf = buf.alloc().buffer(remainingBytes);
376+
final ByteBuf remainingBuf = buf.alloc().buffer(remainingBytes, remainingBytes);
377377
try {
378378
// Copy before modifying the buffer
379379
remainingBuf.writeBytes(buf, remainingBytes);

0 commit comments

Comments
 (0)