geforkt von Mirrors/Paper
4e958e229f
Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com> Co-authored-by: zml <zml@stellardrift.ca> Co-authored-by: Mariell Hoversholm <proximyst@proximyst.com>
66 Zeilen
2.2 KiB
Diff
66 Zeilen
2.2 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Andrew Steinborn <git@steinborn.me>
|
|
Date: Mon, 23 Jul 2018 13:08:19 -0400
|
|
Subject: [PATCH] Optimize RegistryID.c()
|
|
|
|
This is a frequent hotspot for world loading/saving.
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/RegistryID.java b/src/main/java/net/minecraft/server/RegistryID.java
|
|
index 5078a5ce391b445b64b2a16b123a3e3d5841619b..c35764009faeb3d2bb505b135dc542c7a580f254 100644
|
|
--- a/src/main/java/net/minecraft/server/RegistryID.java
|
|
+++ b/src/main/java/net/minecraft/server/RegistryID.java
|
|
@@ -14,12 +14,14 @@ public class RegistryID<K> implements Registry<K> {
|
|
private K[] d;
|
|
private int e;
|
|
private int f;
|
|
+ private java.util.BitSet usedIds; // Paper
|
|
|
|
public RegistryID(int i) {
|
|
i = (int) ((float) i / 0.8F);
|
|
this.b = (K[]) (new Object[i]); // Paper - decompile fix
|
|
this.c = new int[i];
|
|
this.d = (K[]) (new Object[i]); // Paper - decompile fix
|
|
+ this.usedIds = new java.util.BitSet(); // Paper
|
|
}
|
|
|
|
// Paper start - decompile fix
|
|
@@ -51,9 +53,14 @@ public class RegistryID<K> implements Registry<K> {
|
|
}
|
|
|
|
private int c() {
|
|
+ // Paper start
|
|
+ /*
|
|
while (this.e < this.d.length && this.d[this.e] != null) {
|
|
++this.e;
|
|
}
|
|
+ */
|
|
+ this.e = this.usedIds.nextClearBit(0);
|
|
+ // Paper end
|
|
|
|
return this.e;
|
|
}
|
|
@@ -67,6 +74,7 @@ public class RegistryID<K> implements Registry<K> {
|
|
this.d = (K[]) (new Object[i]); // Paper - decompile fix
|
|
this.e = 0;
|
|
this.f = 0;
|
|
+ this.usedIds.clear(); // Paper
|
|
|
|
for (int j = 0; j < ak.length; ++j) {
|
|
if (ak[j] != null) {
|
|
@@ -92,6 +100,7 @@ public class RegistryID<K> implements Registry<K> {
|
|
this.b[k] = k0;
|
|
this.c[k] = i;
|
|
this.d[i] = k0;
|
|
+ this.usedIds.set(i); // Paper
|
|
++this.f;
|
|
if (i == this.e) {
|
|
++this.e;
|
|
@@ -156,6 +165,7 @@ public class RegistryID<K> implements Registry<K> {
|
|
Arrays.fill(this.d, (Object) null);
|
|
this.e = 0;
|
|
this.f = 0;
|
|
+ this.usedIds.clear(); // Paper
|
|
}
|
|
|
|
public int b() {
|