mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-08 09:27:58 +01:00
Use heap buffer for short lived packets
This commit is contained in:
parent
b3655ad82d
commit
622f632989
@ -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();
|
||||
}
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user