mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 23:38:25 +01:00
67522d46ae
* She compiles! Also readded the armorstand ticking patch, thanks cat * Update mob goal api * Misc fixes to make it run drop per playing mob spawns for now
53 lines
2.8 KiB
Diff
53 lines
2.8 KiB
Diff
From 0000000000000000000000000000000000000000 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
--- a/src/main/java/net/minecraft/server/RegistryMaterials.java
|
|
+++ b/src/main/java/net/minecraft/server/RegistryMaterials.java
|
|
@@ -0,0 +0,0 @@ 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();
|
|
- private final BiMap<ResourceKey<T>, T> bb = 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
|
|
+ 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();
|
|
protected Object[] d;
|
|
private int bd;
|
|
@@ -0,0 +0,0 @@ public class RegistryMaterials<T> extends IRegistryWritable<T> {
|
|
this.d = collection.toArray(new Object[collection.size()]);
|
|
}
|
|
|
|
- return SystemUtils.a(this.d, random);
|
|
+ return (T) SystemUtils.a(this.d, random); // Paper - Decompile fix
|
|
}
|
|
|
|
@Override
|
|
@@ -0,0 +0,0 @@ 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));
|
|
}
|
|
@@ -0,0 +0,0 @@ public class RegistryMaterials<T> extends IRegistryWritable<T> {
|
|
|
|
registrymaterials.bb.entrySet().stream().filter((entry) -> {
|
|
return registrymaterials.c((ResourceKey) entry.getKey());
|
|
- }).forEach(com_google_common_collect_immutablemap_builder::put);
|
|
+ }).forEach(entry1 -> com_google_common_collect_immutablemap_builder.put((java.util.Map.Entry<? extends net.minecraft.server.ResourceKey<T>,? extends T>) entry1)); // Paper - compiler fix (expand method reference + add cast)
|
|
return com_google_common_collect_immutablemap_builder.build();
|
|
});
|
|
}
|