mirror of
https://github.com/Minestom/Minestom.git
synced 2024-09-29 15:07:36 +02:00
Simplify writeVarIntHeader
Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
parent
21bac6fba4
commit
f023b1bc07
@ -42,12 +42,9 @@ public final class Utils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void writeVarIntHeader(@NotNull ByteBuffer buffer, int startIndex, int value) {
|
public static void writeVarIntHeader(@NotNull ByteBuffer buffer, int startIndex, int value) {
|
||||||
final int indexCache = buffer.position();
|
buffer.put(startIndex, (byte) (value & 0x7F | 0x80));
|
||||||
buffer.position(startIndex);
|
buffer.put(startIndex + 1, (byte) ((value >>> 7) & 0x7F | 0x80));
|
||||||
buffer.put((byte) (value & 0x7F | 0x80));
|
buffer.put(startIndex + 2, (byte) (value >>> 14));
|
||||||
buffer.put((byte) ((value >>> 7) & 0x7F | 0x80));
|
|
||||||
buffer.put((byte) (value >>> 14));
|
|
||||||
buffer.position(indexCache);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int writeEmptyVarIntHeader(@NotNull ByteBuffer buffer) {
|
public static int writeEmptyVarIntHeader(@NotNull ByteBuffer buffer) {
|
||||||
|
Loading…
Reference in New Issue
Block a user