2020-01-22 03:02:07 +01:00
|
|
|
From 78858b4afe31d5113d447014455190134e115a14 Mon Sep 17 00:00:00 2001
|
2018-08-26 20:11:49 +02:00
|
|
|
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
|
2020-01-22 03:02:07 +01:00
|
|
|
index 2d6a7b3a4..8477febca 100644
|
2018-08-26 20:11:49 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/RegistryMaterials.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/RegistryMaterials.java
|
2019-12-12 01:03:31 +01:00
|
|
|
@@ -16,8 +16,8 @@ import org.apache.logging.log4j.Logger;
|
2019-05-05 10:33:44 +02:00
|
|
|
public class RegistryMaterials<T> extends IRegistryWritable<T> {
|
2019-01-01 04:15:55 +01:00
|
|
|
|
2019-05-05 10:33:44 +02:00
|
|
|
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
|
2019-12-12 01:03:31 +01:00
|
|
|
protected Object[] d;
|
|
|
|
private int V;
|
2018-08-26 20:11:49 +02:00
|
|
|
|
2019-12-12 01:03:31 +01:00
|
|
|
@@ -101,6 +101,6 @@ public class RegistryMaterials<T> extends IRegistryWritable<T> {
|
|
|
|
this.d = collection.toArray(new Object[collection.size()]);
|
2019-01-01 04:15:55 +01:00
|
|
|
}
|
|
|
|
|
2019-12-12 01:03:31 +01:00
|
|
|
- return this.d[random.nextInt(this.d.length)];
|
|
|
|
+ return (T) this.d[random.nextInt(this.d.length)]; // Paper - Decompile fix
|
|
|
|
}
|
|
|
|
}
|
2018-08-26 20:11:49 +02:00
|
|
|
--
|
2020-01-22 03:02:07 +01:00
|
|
|
2.25.0.windows.1
|
2018-08-26 20:11:49 +02:00
|
|
|
|