9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-27 10:59:16 +00:00
Files
Leaf/leaf-server/minecraft-patches/features/0133-Optimize-IdMapper.patch
2025-03-06 10:06:30 +01: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);
}