Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-12-24 15:20:35 +01:00
Update comments in MinecraftCompressEncoder to be more accurate.
Dieser Commit ist enthalten in:
Ursprung
d28022ab60
Commit
fe0d31b0f0
@ -38,9 +38,14 @@ public class MinecraftCompressEncoder extends MessageToByteEncoder<ByteBuf> {
|
||||
@Override
|
||||
protected ByteBuf allocateBuffer(ChannelHandlerContext ctx, ByteBuf msg, boolean preferDirect)
|
||||
throws Exception {
|
||||
// Follow the advice of https://github.com/ebiggers/libdeflate/blob/master/libdeflate.h#L103
|
||||
// here for compression. The maximum buffer size if the data compresses well (which is almost
|
||||
// always the case) is one less the input buffer.
|
||||
// We allocate bytes to be compressed plus 1 byte. This covers two cases:
|
||||
//
|
||||
// - Compression
|
||||
// According to https://github.com/ebiggers/libdeflate/blob/master/libdeflate.h#L103,
|
||||
// if the data compresses well (and we do not have some pathological case) then the maximum
|
||||
// size the compressed size will ever be is the input size minus one.
|
||||
// - Uncompressed
|
||||
// This is fairly obvious - we will then have one more than the uncompressed size.
|
||||
int initialBufferSize = msg.readableBytes() + 1;
|
||||
return MoreByteBufUtils.preferredBuffer(ctx.alloc(), compressor, initialBufferSize);
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren