9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-26 10:29:13 +00:00

[ci skip] small cleanup

This commit is contained in:
Taiyou06
2025-03-16 20:37:49 +01:00
parent f6aa7635f3
commit 7e3022e313
8 changed files with 4 additions and 43 deletions

View File

@@ -1,43 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Taiyou06 <kaandindar21@gmail.com>
Date: Mon, 24 Feb 2025 16:33:46 +0100
Subject: [PATCH] Replace IdMapper id map with optimized collection
diff --git a/net/minecraft/core/IdMapper.java b/net/minecraft/core/IdMapper.java
index 439dc29b8ee8a1dc2ec63c00a9727a37bb697bad..be80e0bd9b44f7a04075827f0a8f22a126031c07 100644
--- a/net/minecraft/core/IdMapper.java
+++ b/net/minecraft/core/IdMapper.java
@@ -11,7 +11,7 @@ import javax.annotation.Nullable;
public class IdMapper<T> implements IdMap<T> {
private int nextId;
- private final Reference2IntMap<T> tToId;
+ private final it.unimi.dsi.fastutil.objects.Object2IntOpenCustomHashMap<T> tToId; // Leaf - Optimize IdMapper
private final List<T> idToT;
public IdMapper() {
@@ -20,7 +20,22 @@ public class IdMapper<T> implements IdMap<T> {
public IdMapper(int expectedSize) {
this.idToT = Lists.newArrayListWithExpectedSize(expectedSize);
- this.tToId = new Reference2IntOpenHashMap<>(expectedSize);
+ // Leaf start - Replace IdMapper id map with optimized collection
+ this.tToId = new it.unimi.dsi.fastutil.objects.Object2IntOpenCustomHashMap<>(
+ expectedSize,
+ new it.unimi.dsi.fastutil.Hash.Strategy<>() {
+ @Override
+ public int hashCode(T o) {
+ return System.identityHashCode(o);
+ }
+
+ @Override
+ public boolean equals(T a, T b) {
+ return a == b;
+ }
+ }
+ );
+ // Leaf end - Replace IdMapper id map with optimized collection
this.tToId.defaultReturnValue(-1);
}

View File

@@ -3,6 +3,10 @@ From: Taiyou06 <kaandindar21@gmail.com>
Date: Mon, 24 Feb 2025 21:33:24 +0100
Subject: [PATCH] Rewrite ClientboundLightUpdatePacketData
On writing operations:
At 256 sections with 0.75 fill ratio: 18x faster (333.489 μs → 18.606 μs)
At 256 sections with 0.5 fill ratio: 13.5x faster (147.804 μs → 10.962 μs)
diff --git a/net/minecraft/network/protocol/game/ClientboundLightUpdatePacketData.java b/net/minecraft/network/protocol/game/ClientboundLightUpdatePacketData.java
index a0b54f3a3d11e0f0f1cb806406a870ba36da8f07..234280499fe1bc495bcdd4c3e144d1f99b7e6975 100644