9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-27 19:09:22 +00:00
Files
Leaf/leaf-server/minecraft-patches/features/0134-Optimize-IdMapper.patch
Taiyou cd7689b16f Chunk improvements (#231)
* perf: SpatialPlayerIndex for isChunkNearPlayer

* perf: ensureCapacity with collectTickingChunks

* perf: optimize getSlopeDistance

* perf: optimize AABB Intersections

* perf: implement custom arrays for regions and caches

* perf: Improve SortedArraySet sorting (needs testing)

* rebase 1.21.4

* perf: optimize ClientBoundLightUpdatePacketData

* perf: O(1) Array Writes during Chunk Loading

* perf: Optimize LinearPalette (no not the linear format)

* perf: Rewrite ConcurrentLongHashSet

* rebase 1.21.4

* Fix Multithreaded Tracker (#236)

* duke gonna arrest me

* i hate git v2

* rebase

* dont worry ill change the name of this patch

* perf: Rewrite ConcurrentLongHashSet again

* perf: Optimize sendChunk

* [ci skip]

* cleanup

* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

* cleanup

* remove streams on LinearPalette and SerializableChunkData

* actually commit them lmao

* actually commit them lmao 2

* fix

* rebase

* perf: clone less (could help with skyblocks)

* perf: more unload stuff

* perf: manual loop unrolling and bulk copy

* initial size for SerializeableChunkData

* perf: async chunkSend

* cleanup asyncChunkSend

* remove experimental tag

* rebase

---------

Co-authored-by: Creeam <102713261+HaHaWTH@users.noreply.github.com>
Co-authored-by: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
2025-03-05 22:45:26 +03:00

42 lines
1.5 KiB
Diff

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] Optimize IdMapper
diff --git a/net/minecraft/core/IdMapper.java b/net/minecraft/core/IdMapper.java
index 439dc29b8ee8a1dc2ec63c00a9727a37bb697bad..b063cdb0667de69c5ab5ce3895a0adfb19d6a28f 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;
private final List<T> idToT;
public IdMapper() {
@@ -20,7 +20,20 @@ public class IdMapper<T> implements IdMap<T> {
public IdMapper(int expectedSize) {
this.idToT = Lists.newArrayListWithExpectedSize(expectedSize);
- this.tToId = new Reference2IntOpenHashMap<>(expectedSize);
+ this.tToId = new it.unimi.dsi.fastutil.objects.Object2IntOpenCustomHashMap<>(
+ expectedSize,
+ new it.unimi.dsi.fastutil.Hash.Strategy<T>() {
+ @Override
+ public int hashCode(T o) {
+ return System.identityHashCode(o);
+ }
+
+ @Override
+ public boolean equals(T a, T b) {
+ return a == b;
+ }
+ }
+ );
this.tToId.defaultReturnValue(-1);
}