Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 04:20:04 +01:00
36f34f01c0
Upstream has released updates that appears to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: da9ef3c5 #496: Add methods to get/set ItemStacks in EquipmentSlots 3abebc9f #492: Let Tameable extend Animals rather than Entity 941111a0 #495: Expose ItemStack and hand used in PlayerShearEntityEvent 4fe19cae #494: InventoryView - Add missing Brewing FUEL_TIME CraftBukkit Changes:933e9094
#664: Add methods to get/set ItemStacks in EquipmentSlots18722312
#662: Expose ItemStack and hand used in PlayerShearEntityEvent
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 e15d286710ed66a01bfb6b60f8735b837efb3fd7..e8a48b9a4c999281869dfb85577c2b44d6e30eb7 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
|
|
}
|
|
|
|
public int getId(@Nullable K k0) {
|
|
@@ -44,9 +46,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;
|
|
}
|
|
@@ -60,6 +67,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) {
|
|
@@ -85,6 +93,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;
|
|
@@ -149,6 +158,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() {
|