Paper/Spigot-Server-Patches/0296-Optimize-RegistryMaterials.patch
Spottedleaf 2f782a6652 Updated Upstream (CraftBukkit)
Upstream has released updates that appears to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

CraftBukkit Changes:
17543ecf SPIGOT-5035: Error Using Virtual Merchant GUI
0fc6922b SPIGOT-5028: Villager#setVillagerExperience() doesn't work
bdbdbe44 SPIGOT-5024: Fox error - Unknown target reason
2019-06-06 16:56:51 +01:00

39 lines
1.7 KiB
Diff

From 12e27b2338d7d8288e2827868316aacaf05dc9ac 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 f291e05b26..fed38e6ef0 100644
--- a/src/main/java/net/minecraft/server/RegistryMaterials.java
+++ b/src/main/java/net/minecraft/server/RegistryMaterials.java
@@ -16,9 +16,9 @@ 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 Object[] d;
+ 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 T[] d; // Paper - Decompile fix
private int R;
public RegistryMaterials() {}
@@ -98,7 +98,7 @@ public class RegistryMaterials<T> extends IRegistryWritable<T> {
return null;
}
- this.d = collection.toArray(new Object[collection.size()]);
+ this.d = (T[]) collection.toArray(new Object[collection.size()]); // Paper - Decompile fix
}
return this.d[random.nextInt(this.d.length)];
--
2.21.0