Archiviert
13
0
Dieses Repository wurde am 2024-12-25 archiviert. Du kannst Dateien ansehen und es klonen, aber nicht pushen oder Issues/Pull-Requests öffnen.
Paper-Old/Spigot-Server-Patches/0299-Optimize-RegistryID.c.patch
Zach Brown 8ed2992da9
Make scan-for-legacy-ender-dragon config work again
Portion of diff was dropped in the mappings update commit.

Also remove the option to remove invalid statistics. The server will
automatically do this now as of... 1.13?, our option wasn't even doing anything.
2018-12-14 20:17:27 -05:00

69 Zeilen
2.1 KiB
Diff

From 2cd962b21d2017d73d53cfbdf8e07d416a924e07 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 d03ac0e70..9242999f7 100644
--- a/src/main/java/net/minecraft/server/RegistryID.java
+++ b/src/main/java/net/minecraft/server/RegistryID.java
@@ -13,12 +13,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]);
this.c = new int[i];
this.d = (K[])(new Object[i]);
+ this.usedIds = new java.util.BitSet(); // Paper
}
public int getId(@Nullable K object) {
@@ -41,9 +43,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;
}
@@ -56,6 +63,7 @@ public class RegistryID<K> implements Registry<K> {
this.d = (K[])(new Object[i]);
this.e = 0;
this.f = 0;
+ this.usedIds.clear(); // Paper
for(int j = 0; j < aobject.length; ++j) {
if (aobject[j] != null) {
@@ -80,6 +88,7 @@ public class RegistryID<K> implements Registry<K> {
this.b[l] = object;
this.c[l] = i;
this.d[i] = object;
+ this.usedIds.set(i); // Paper
++this.f;
if (i == this.e) {
++this.e;
@@ -140,6 +149,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() {
--
2.20.0