mirror of
https://github.com/Minestom/Minestom.git
synced 2024-11-13 22:25:53 +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) {
|
if (encrypted) {
|
||||||
final Cipher cipher = encryptCipher;
|
final Cipher cipher = encryptCipher;
|
||||||
// Encrypt data first
|
// Encrypt data first
|
||||||
final int remainingBytes = localBuffer.readableBytes();
|
ByteBuffer cipherInput = localBuffer.asByteBuffer(0, localBuffer.writerOffset());
|
||||||
final byte[] bytes = localBuffer.readRemainingBytes();
|
ByteBuffer cipherOutput = getPooledBuffer().asByteBuffer(0, BUFFER_SIZE);
|
||||||
byte[] outTempArray = new byte[cipher.getOutputSize(remainingBytes)];
|
|
||||||
try {
|
try {
|
||||||
cipher.update(bytes, 0, remainingBytes, outTempArray);
|
cipher.update(cipherInput, cipherOutput);
|
||||||
} catch (ShortBufferException e) {
|
} catch (ShortBufferException e) {
|
||||||
MinecraftServer.getExceptionManager().handleException(e);
|
MinecraftServer.getExceptionManager().handleException(e);
|
||||||
}
|
}
|
||||||
localBuffer.clear();
|
localBuffer.clear();
|
||||||
localBuffer.writeBytes(outTempArray);
|
localBuffer.write(cipherOutput.flip());
|
||||||
}
|
}
|
||||||
|
|
||||||
this.waitingBuffers.add(localBuffer);
|
this.waitingBuffers.add(localBuffer);
|
||||||
|
@ -14,7 +14,6 @@ import java.util.function.Consumer;
|
|||||||
public final class EntityUtils {
|
public final class EntityUtils {
|
||||||
|
|
||||||
private EntityUtils() {
|
private EntityUtils() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void forEachRange(@NotNull Instance instance, @NotNull Point point,
|
public static void forEachRange(@NotNull Instance instance, @NotNull Point point,
|
||||||
|
Loading…
Reference in New Issue
Block a user