3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-17 03:50:08 +01:00
Paper/Spigot-Server-Patches/0302-Optimize-RegistryID.c.patch
Aikar 2365b308c8
Updated Upstream (Bukkit/CraftBukkit/Spigot)
Upstream has released updates that appears to apply and compile correctly.

This update has been tested to ensure that World Conversion still occurs correctly.

Bukkit Changes:
0812ce2c SPIGOT-4397: isChunkGenerated API

CraftBukkit Changes:
4824655c SPIGOT-4398: Upgrade to ASM 6.2.1 for better Java 11 support
eea43870 MC-134115: Fix issues converting tile entities
1a7f2d10 SPIGOT-4397: isChunkGenerated API
40aed54d SPIGOT-4396: Improve vehicle movement

Spigot Changes:
f6a273b1 Rebuild patches
2018-09-26 22:35:46 -04:00

69 Zeilen
2.1 KiB
Diff

From d7257593d68d82a105f007a16dcae0bf82374bf2 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 d03ac0e70c..9242999f70 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.19.0