Paper/Spigot-Server-Patches/0283-Optimize-RegistryMaterials.patch
Aikar 57dd397155
Updated Upstream (Bukkit/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

Bukkit Changes:
b999860d SPIGOT-2304: Add LootGenerateEvent

CraftBukkit Changes:
77fd87e4 SPIGOT-2304: Implement LootGenerateEvent
a1a705ee SPIGOT-5566: Doused campfires & fires should call EntityChangeBlockEvent
41712edd SPIGOT-5707: PersistentDataHolder not Persistent on API dropped Item
2020-05-01 18:03:57 -04:00

36 lines
1.5 KiB
Diff

From 1bf9590e979cd9ffaa3c3a10b3c6f70e7d6b1a4e 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 2d6a7b3a47..8477febca2 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.26.2