From 84d71fb5336eb44c32edbe99ef569261b1e59a51 Mon Sep 17 00:00:00 2001 From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com> Date: Wed, 12 Mar 2025 16:08:10 -0400 Subject: [PATCH] [ci skip] cleanup (8/14) --- ...> 0134-Slightly-optimized-VarInt-write.patch} | 16 ++++++++++------ ...ewrite-ClientboundLightUpdatePacketData.patch | 16 +++------------- ...-Optimizations-on-SerializableChunkData.patch | 11 ----------- 3 files changed, 13 insertions(+), 30 deletions(-) rename leaf-server/minecraft-patches/features/{0134-Slight-optimizations-to-VarInt.patch => 0134-Slightly-optimized-VarInt-write.patch} (84%) diff --git a/leaf-server/minecraft-patches/features/0134-Slight-optimizations-to-VarInt.patch b/leaf-server/minecraft-patches/features/0134-Slightly-optimized-VarInt-write.patch similarity index 84% rename from leaf-server/minecraft-patches/features/0134-Slight-optimizations-to-VarInt.patch rename to leaf-server/minecraft-patches/features/0134-Slightly-optimized-VarInt-write.patch index e7a6a588..0d33e5b0 100644 --- a/leaf-server/minecraft-patches/features/0134-Slight-optimizations-to-VarInt.patch +++ b/leaf-server/minecraft-patches/features/0134-Slightly-optimized-VarInt-write.patch @@ -1,18 +1,19 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Taiyou06 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; } + diff --git a/leaf-server/minecraft-patches/features/0135-Rewrite-ClientboundLightUpdatePacketData.patch b/leaf-server/minecraft-patches/features/0135-Rewrite-ClientboundLightUpdatePacketData.patch index fc49511e..4dd20597 100644 --- a/leaf-server/minecraft-patches/features/0135-Rewrite-ClientboundLightUpdatePacketData.patch +++ b/leaf-server/minecraft-patches/features/0135-Rewrite-ClientboundLightUpdatePacketData.patch @@ -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 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 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 } } diff --git a/leaf-server/minecraft-patches/features/0136-Some-Optimizations-on-SerializableChunkData.patch b/leaf-server/minecraft-patches/features/0136-Some-Optimizations-on-SerializableChunkData.patch index 71e5ed23..10c295fc 100644 --- a/leaf-server/minecraft-patches/features/0136-Some-Optimizations-on-SerializableChunkData.patch +++ b/leaf-server/minecraft-patches/features/0136-Some-Optimizations-on-SerializableChunkData.patch @@ -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 - ); - } - }