2020-05-06 09:48:49 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2018-08-26 18:11:49 +00: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-06-25 14:09:55 +00:00
|
|
|
index c60140a283df47edf23fe4f54a2c1d2fca7593f8..7189204ee57343b3381e8c83eb5a5281a0e0962f 100644
|
2018-08-26 18:11:49 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/RegistryMaterials.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/RegistryMaterials.java
|
2020-06-25 14:09:55 +00:00
|
|
|
@@ -25,9 +25,9 @@ import org.apache.logging.log4j.Logger;
|
2019-05-05 08:33:44 +00:00
|
|
|
public class RegistryMaterials<T> extends IRegistryWritable<T> {
|
2019-01-01 03:15:55 +00:00
|
|
|
|
2019-05-05 08:33:44 +00:00
|
|
|
protected static final Logger LOGGER = LogManager.getLogger();
|
|
|
|
- protected final RegistryID<T> b = new RegistryID<>(256);
|
|
|
|
- protected final BiMap<MinecraftKey, T> c = HashBiMap.create();
|
2020-06-25 14:09:55 +00:00
|
|
|
- private final BiMap<ResourceKey<T>, T> bb = HashBiMap.create();
|
2019-05-05 08:33:44 +00:00
|
|
|
+ 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
|
2020-06-25 14:09:55 +00:00
|
|
|
+ private final BiMap<ResourceKey<T>, T> bb = HashBiMap.create(2048); // Paper - use bigger expected size to reduce collisions
|
|
|
|
private final Set<ResourceKey<T>> bc = Sets.newIdentityHashSet();
|
2019-12-12 00:03:31 +00:00
|
|
|
protected Object[] d;
|
2020-06-25 14:09:55 +00:00
|
|
|
private int bd;
|
|
|
|
@@ -124,7 +124,7 @@ public class RegistryMaterials<T> extends IRegistryWritable<T> {
|
2019-12-12 00:03:31 +00:00
|
|
|
this.d = collection.toArray(new Object[collection.size()]);
|
2019-01-01 03:15:55 +00:00
|
|
|
}
|
|
|
|
|
2020-06-25 14:09:55 +00:00
|
|
|
- return SystemUtils.a(this.d, random);
|
|
|
|
+ return (T) SystemUtils.a(this.d, random); // Paper - Decompile fix
|
2019-12-12 00:03:31 +00:00
|
|
|
}
|
2020-06-25 14:09:55 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
@@ -164,7 +164,7 @@ public class RegistryMaterials<T> extends IRegistryWritable<T> {
|
|
|
|
Iterator iterator = registrymaterials.b.iterator();
|
|
|
|
|
|
|
|
while (iterator.hasNext()) {
|
|
|
|
- T t0 = iterator.next();
|
|
|
|
+ T t0 = (T) iterator.next(); // Paper - Decompile fix
|
|
|
|
|
|
|
|
builder.add(Pair.of(registrymaterials.c(t0).get(), t0));
|
|
|
|
}
|