13
0
geforkt von Mirrors/Velocity

Reduce object allocations in MinecraftVarintFrameDecoder.

Dieser Commit ist enthalten in:
Andrew Steinborn 2019-01-11 17:46:57 -05:00
Ursprung 5dbe6aa808
Commit 2b7b33bd42

Datei anzeigen

@ -19,6 +19,7 @@ public class MinecraftVarintFrameDecoder extends ByteToMessageDecoder {
int origReaderIndex = in.readerIndex(); int origReaderIndex = in.readerIndex();
byte[] lenBuf = new byte[3]; byte[] lenBuf = new byte[3];
ByteBuf wrappedBuf = Unpooled.wrappedBuffer(lenBuf);
for (int i = 0; i < lenBuf.length; i++) { for (int i = 0; i < lenBuf.length; i++) {
if (!in.isReadable()) { if (!in.isReadable()) {
in.readerIndex(origReaderIndex); in.readerIndex(origReaderIndex);
@ -27,7 +28,7 @@ public class MinecraftVarintFrameDecoder extends ByteToMessageDecoder {
lenBuf[i] = in.readByte(); lenBuf[i] = in.readByte();
if (lenBuf[i] > 0) { if (lenBuf[i] > 0) {
int packetLength = ProtocolUtils.readVarInt(Unpooled.wrappedBuffer(lenBuf)); int packetLength = ProtocolUtils.readVarInt(wrappedBuf);
if (packetLength == 0) { if (packetLength == 0) {
return; return;
} }