e4602b6d48
This patch appears to be no longer relevant, and is seemingly a leading cause of datapack performance being horrific
35 lines
1.5 KiB
Diff
35 lines
1.5 KiB
Diff
From fa26bac76e8d9a8d2e42958564faf5613d324084 Mon Sep 17 00:00:00 2001
|
|
From: Aikar <aikar@aikar.co>
|
|
Date: Sun, 26 Aug 2018 20:49:50 -0400
|
|
Subject: [PATCH] Optimize RegistryMaterials
|
|
|
|
Use larger initial sizes to increase bucket capacity on the BiMap
|
|
|
|
BiMap.get was seen to be using a good bit of CPU time.
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/RegistryMaterials.java b/src/main/java/net/minecraft/server/RegistryMaterials.java
|
|
index 2d6a7b3a4..8477febca 100644
|
|
--- a/src/main/java/net/minecraft/server/RegistryMaterials.java
|
|
+++ b/src/main/java/net/minecraft/server/RegistryMaterials.java
|
|
@@ -16,8 +16,8 @@ import org.apache.logging.log4j.Logger;
|
|
public class RegistryMaterials<T> extends IRegistryWritable<T> {
|
|
|
|
protected static final Logger LOGGER = LogManager.getLogger();
|
|
- protected final RegistryID<T> b = new RegistryID<>(256);
|
|
- protected final BiMap<MinecraftKey, T> c = HashBiMap.create();
|
|
+ protected final RegistryID<T> b = new RegistryID<>(2048); // Paper - use bigger expected size to reduce collisions
|
|
+ protected final BiMap<MinecraftKey, T> c = HashBiMap.create(2048); // Paper - use bigger expected size to reduce collisions
|
|
protected Object[] d;
|
|
private int V;
|
|
|
|
@@ -101,6 +101,6 @@ public class RegistryMaterials<T> extends IRegistryWritable<T> {
|
|
this.d = collection.toArray(new Object[collection.size()]);
|
|
}
|
|
|
|
- return this.d[random.nextInt(this.d.length)];
|
|
+ return (T) this.d[random.nextInt(this.d.length)]; // Paper - Decompile fix
|
|
}
|
|
}
|
|
--
|
|
2.25.1
|
|
|