Use heap buffer for short lived packets

This commit is contained in:
themode 2021-03-25 16:51:36 +01:00
parent b3655ad82d
commit 622f632989
2 changed files with 3 additions and 3 deletions

View File

@ -176,7 +176,7 @@ public class NettyPlayerConnection extends PlayerConnection {
} else if (message instanceof ServerPacket) {
final ServerPacket serverPacket = (ServerPacket) message;
synchronized (tickBuffer) {
final ByteBuf framedPacket = PacketUtils.createFramedPacket(serverPacket, true);
final ByteBuf framedPacket = PacketUtils.createFramedPacket(serverPacket, false);
tickBuffer.writeBytes(framedPacket);
framedPacket.release();
}

View File

@ -214,14 +214,14 @@ public final class PacketUtils {
packetBuf = compressedBuf;
} else {
// Packet too small
ByteBuf uncompressedLengthBuffer = directBuffer ? BufUtils.getBuffer(true, 1) : Unpooled.buffer();
ByteBuf uncompressedLengthBuffer = Unpooled.buffer();
Utils.writeVarIntBuf(uncompressedLengthBuffer, 0);
packetBuf = Unpooled.wrappedBuffer(uncompressedLengthBuffer, packetBuf);
}
}
// Write the final length of the packet
ByteBuf packetLengthBuffer = directBuffer ? BufUtils.getBuffer(true, 5) : Unpooled.buffer();
ByteBuf packetLengthBuffer = Unpooled.buffer();
Utils.writeVarIntBuf(packetLengthBuffer, packetBuf.readableBytes());
return Unpooled.wrappedBuffer(packetLengthBuffer, packetBuf);