3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-25 15:50:10 +01:00

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
Dieser Commit ist enthalten in:
Nassim Jahnke 2024-11-27 11:32:03 +01:00
Ursprung d3f92ce9b8
Commit 2f08f0d58c
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: EF6771C01F6EF02F

Datei anzeigen

@ -373,7 +373,7 @@ public class UserConnectionImpl implements UserConnection {
// Instead of allocating a possible unnecessarily large buffer to write the wrapper contents to,
// only allocate the remaining bytes and write the rest to the original buf's head directly.
final ByteBuf remainingBuf = buf.alloc().buffer(remainingBytes);
final ByteBuf remainingBuf = buf.alloc().buffer(remainingBytes, remainingBytes);
try {
// Copy before modifying the buffer
remainingBuf.writeBytes(buf, remainingBytes);