mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-26 02:19:19 +00:00
[ci skip] cleanup (8/14)
This commit is contained in:
@@ -1,18 +1,19 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Taiyou06 <kaandindar21@gmail.com>
|
||||
Date: Mon, 24 Feb 2025 21:11:09 +0100
|
||||
Subject: [PATCH] Slight optimizations to VarInt
|
||||
Subject: [PATCH] Slightly optimized VarInt#write
|
||||
|
||||
Use switch case instead of if-else for branches. It makes it able to use
|
||||
tableswitch instruction for better efficiency.
|
||||
|
||||
diff --git a/net/minecraft/network/VarInt.java b/net/minecraft/network/VarInt.java
|
||||
index 6f8dd31582f0e1d3a71acc7a142c1f4ec0539d9e..043db53ee627ac13e3a952c8d5beba5065ecbb48 100644
|
||||
index 6f8dd31582f0e1d3a71acc7a142c1f4ec0539d9e..4c9095995e8515c61d54f1c056be35a12a138ef3 100644
|
||||
--- a/net/minecraft/network/VarInt.java
|
||||
+++ b/net/minecraft/network/VarInt.java
|
||||
@@ -51,35 +51,41 @@ public class VarInt {
|
||||
}
|
||||
@@ -52,35 +52,44 @@ public class VarInt {
|
||||
|
||||
public static ByteBuf write(ByteBuf buffer, int value) {
|
||||
- // Gale start - Velocity - optimized VarInt#write
|
||||
// Gale start - Velocity - optimized VarInt#write
|
||||
- if ((value & 0xFFFFFF80) == 0) {
|
||||
- buffer.writeByte(value);
|
||||
- } else if ((value & 0xFFFFC000) == 0) {
|
||||
@@ -41,7 +42,7 @@ index 6f8dd31582f0e1d3a71acc7a142c1f4ec0539d9e..043db53ee627ac13e3a952c8d5beba50
|
||||
- | 0x80808080;
|
||||
- buffer.writeInt(w);
|
||||
- buffer.writeByte(value >>> 28);
|
||||
+ // Gale start - Velocity - optimized VarInt#write // Leaf - help JIT by using switch case
|
||||
+ // Leaf start - Slightly optimized VarInt#write
|
||||
+ int bytesNeeded = getByteSize(value);
|
||||
+
|
||||
+ switch (bytesNeeded) {
|
||||
@@ -77,5 +78,8 @@ index 6f8dd31582f0e1d3a71acc7a142c1f4ec0539d9e..043db53ee627ac13e3a952c8d5beba50
|
||||
+ buffer.writeByte(value >>> 28);
|
||||
+ break;
|
||||
}
|
||||
+ // Leaf end - Slightly optimized VarInt#write
|
||||
+
|
||||
return buffer;
|
||||
}
|
||||
|
||||
@@ -5,19 +5,9 @@ Subject: [PATCH] Rewrite ClientboundLightUpdatePacketData
|
||||
|
||||
|
||||
diff --git a/net/minecraft/network/protocol/game/ClientboundLightUpdatePacketData.java b/net/minecraft/network/protocol/game/ClientboundLightUpdatePacketData.java
|
||||
index a0b54f3a3d11e0f0f1cb806406a870ba36da8f07..2ef45811f3a3a763f389e8e6e9eeaf255cf668e6 100644
|
||||
index a0b54f3a3d11e0f0f1cb806406a870ba36da8f07..304365f61d6fde632c1c09cb889d466ee70aa518 100644
|
||||
--- a/net/minecraft/network/protocol/game/ClientboundLightUpdatePacketData.java
|
||||
+++ b/net/minecraft/network/protocol/game/ClientboundLightUpdatePacketData.java
|
||||
@@ -1,8 +1,8 @@
|
||||
package net.minecraft.network.protocol.game;
|
||||
|
||||
-import com.google.common.collect.Lists;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.util.BitSet;
|
||||
+import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.core.SectionPos;
|
||||
@@ -16,30 +16,109 @@ import net.minecraft.world.level.lighting.LevelLightEngine;
|
||||
|
||||
public class ClientboundLightUpdatePacketData {
|
||||
@@ -222,7 +212,7 @@ index a0b54f3a3d11e0f0f1cb806406a870ba36da8f07..2ef45811f3a3a763f389e8e6e9eeaf25
|
||||
|
||||
public List<byte[]> getSkyUpdates() {
|
||||
- return this.skyUpdates;
|
||||
+ return this.skyUpdateCount > 0 ? Arrays.asList(this.skyUpdates) : List.of();
|
||||
+ return this.skyUpdateCount > 0 ? Arrays.asList(this.skyUpdates) : List.of(); // Leaf - Rewrite ClientboundLightUpdatePacketData
|
||||
}
|
||||
|
||||
public BitSet getBlockYMask() {
|
||||
@@ -231,6 +221,6 @@ index a0b54f3a3d11e0f0f1cb806406a870ba36da8f07..2ef45811f3a3a763f389e8e6e9eeaf25
|
||||
|
||||
public List<byte[]> getBlockUpdates() {
|
||||
- return this.blockUpdates;
|
||||
+ return this.blockUpdateCount > 0 ? Arrays.asList(this.blockUpdates) : List.of();
|
||||
+ return this.blockUpdateCount > 0 ? Arrays.asList(this.blockUpdates) : List.of(); // Leaf - Rewrite ClientboundLightUpdatePacketData
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,14 +76,3 @@ index 6b6aaeca14178b5b709e20ae13552d42217f15c0..c10ed10dd843bfa12be3f80a244cda94
|
||||
CompoundTag compoundTag = packStructureData(
|
||||
StructurePieceSerializationContext.fromLevel(level), pos, chunk.getAllStarts(), chunk.getAllReferences()
|
||||
);
|
||||
@@ -605,8 +615,8 @@ public record SerializableChunkData(
|
||||
list,
|
||||
list2,
|
||||
list1,
|
||||
- compoundTag
|
||||
- , persistentDataContainer // CraftBukkit - persistentDataContainer
|
||||
+ compoundTag,
|
||||
+ persistentDataContainer // CraftBukkit - persistentDataContainer
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user