From 62703780e1870b51d1e2e9bc206bbae317587743 Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Sat, 27 Jun 2020 21:33:05 -0400 Subject: [PATCH] Fix a few areas of concern spotted by JITWatch --- .../natives/compression/LibdeflateVelocityCompressor.java | 2 -- .../natives/encryption/NativeVelocityCipher.java | 1 - .../proxy/protocol/netty/MinecraftCompressEncoder.java | 3 +-- 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/native/src/main/java/com/velocitypowered/natives/compression/LibdeflateVelocityCompressor.java b/native/src/main/java/com/velocitypowered/natives/compression/LibdeflateVelocityCompressor.java index d8c95b37..0638f532 100644 --- a/native/src/main/java/com/velocitypowered/natives/compression/LibdeflateVelocityCompressor.java +++ b/native/src/main/java/com/velocitypowered/natives/compression/LibdeflateVelocityCompressor.java @@ -48,8 +48,6 @@ public class LibdeflateVelocityCompressor implements VelocityCompressor { @Override public void deflate(ByteBuf source, ByteBuf destination) throws DataFormatException { ensureNotDisposed(); - source.memoryAddress(); - destination.memoryAddress(); while (true) { long sourceAddress = source.memoryAddress() + source.readerIndex(); diff --git a/native/src/main/java/com/velocitypowered/natives/encryption/NativeVelocityCipher.java b/native/src/main/java/com/velocitypowered/natives/encryption/NativeVelocityCipher.java index cd0bcbd0..48e588ed 100644 --- a/native/src/main/java/com/velocitypowered/natives/encryption/NativeVelocityCipher.java +++ b/native/src/main/java/com/velocitypowered/natives/encryption/NativeVelocityCipher.java @@ -31,7 +31,6 @@ public class NativeVelocityCipher implements VelocityCipher { @Override public void process(ByteBuf source) { ensureNotDisposed(); - source.memoryAddress(); long base = source.memoryAddress() + source.readerIndex(); int len = source.readableBytes(); diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/MinecraftCompressEncoder.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/MinecraftCompressEncoder.java index c36bfd8a..b0d9fd37 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/MinecraftCompressEncoder.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/MinecraftCompressEncoder.java @@ -41,8 +41,7 @@ public class MinecraftCompressEncoder extends MessageToByteEncoder { // 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. - int offset = msg.readableBytes() < threshold ? 1 : -1; - int initialBufferSize = msg.readableBytes() + offset; + int initialBufferSize = msg.readableBytes() + 1; return MoreByteBufUtils.preferredBuffer(ctx.alloc(), compressor, initialBufferSize); }