mirror of
https://github.com/Minestom/Minestom.git
synced 2024-11-05 18:32:28 +01:00
Remove unnecessary allocation during encryption
Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
parent
344003f36a
commit
526108b896
@ -279,16 +279,15 @@ public class PlayerSocketConnection extends PlayerConnection {
|
||||
if (encrypted) {
|
||||
final Cipher cipher = encryptCipher;
|
||||
// Encrypt data first
|
||||
final int remainingBytes = localBuffer.readableBytes();
|
||||
final byte[] bytes = localBuffer.readRemainingBytes();
|
||||
byte[] outTempArray = new byte[cipher.getOutputSize(remainingBytes)];
|
||||
ByteBuffer cipherInput = localBuffer.asByteBuffer(0, localBuffer.writerOffset());
|
||||
ByteBuffer cipherOutput = getPooledBuffer().asByteBuffer(0, BUFFER_SIZE);
|
||||
try {
|
||||
cipher.update(bytes, 0, remainingBytes, outTempArray);
|
||||
cipher.update(cipherInput, cipherOutput);
|
||||
} catch (ShortBufferException e) {
|
||||
MinecraftServer.getExceptionManager().handleException(e);
|
||||
}
|
||||
localBuffer.clear();
|
||||
localBuffer.writeBytes(outTempArray);
|
||||
localBuffer.write(cipherOutput.flip());
|
||||
}
|
||||
|
||||
this.waitingBuffers.add(localBuffer);
|
||||
|
@ -14,7 +14,6 @@ import java.util.function.Consumer;
|
||||
public final class EntityUtils {
|
||||
|
||||
private EntityUtils() {
|
||||
|
||||
}
|
||||
|
||||
public static void forEachRange(@NotNull Instance instance, @NotNull Point point,
|
||||
|
Loading…
Reference in New Issue
Block a user