From 9bcf89b6770869044bcb393443973174bb12b8ea Mon Sep 17 00:00:00 2001 From: TheMode Date: Fri, 6 Aug 2021 14:30:55 +0200 Subject: [PATCH] Simplify var-int reading --- .../java/net/minestom/server/utils/binary/BinaryBuffer.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/net/minestom/server/utils/binary/BinaryBuffer.java b/src/main/java/net/minestom/server/utils/binary/BinaryBuffer.java index 8f7b862ff..f996c9252 100644 --- a/src/main/java/net/minestom/server/utils/binary/BinaryBuffer.java +++ b/src/main/java/net/minestom/server/utils/binary/BinaryBuffer.java @@ -52,8 +52,7 @@ public final class BinaryBuffer { public int readVarInt() { int value = 0; - final int maxRead = Math.min(5, readableBytes()); - for (int i = 0; i < maxRead; i++) { + for (int i = 0; i < 5; i++) { final int offset = readerOffset + i; final byte k = nioBuffer.get(offset); value |= (k & 0x7F) << i * 7; @@ -62,7 +61,6 @@ public final class BinaryBuffer { return value; } } - this.readerOffset += maxRead; throw new RuntimeException("VarInt is too big"); }