mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-29 15:49:00 +01:00
parent
fea7cd7e3c
commit
9399a74c2a
2 changed files with 100 additions and 1 deletions
|
@ -497,4 +497,6 @@ index f4d1ade5..65b7a076 100644
|
|||
// Paper end
|
||||
|
||||
/**
|
||||
--
|
||||
--
|
||||
2.17.0 (Apple Git-106)
|
||||
|
||||
|
|
97
Spigot-Server-Patches/Optimize-RegistryID.c.patch
Normal file
97
Spigot-Server-Patches/Optimize-RegistryID.c.patch
Normal file
|
@ -0,0 +1,97 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Andrew Steinborn <git@steinborn.me>
|
||||
Date: Mon, 23 Jul 2018 12:50:18 -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 3b8f6ec1..163da432 100644
|
||||
--- a/src/main/java/net/minecraft/server/RegistryID.java
|
||||
+++ b/src/main/java/net/minecraft/server/RegistryID.java
|
||||
@@ -0,0 +0,0 @@ import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
-public class RegistryID<K> implements Registry<K> {
|
||||
+public class RegistryID<K> implements Registry { // Paper - decompile fix
|
||||
|
||||
private static final Object a = null;
|
||||
private K[] b;
|
||||
@@ -0,0 +0,0 @@ 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 = (Object[]) (new Object[i]);
|
||||
+ this.b = (K[]) (new Object[i]); // Paper - decompile fix
|
||||
this.c = new int[i];
|
||||
- this.d = (Object[]) (new Object[i]);
|
||||
+ this.d = (K[]) (new Object[i]); // Paper - decompile fix
|
||||
+ this.usedIds = new java.util.BitSet(); // Paper
|
||||
}
|
||||
|
||||
public int getId(@Nullable K k0) {
|
||||
@@ -0,0 +0,0 @@ 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;
|
||||
}
|
||||
|
||||
private void d(int i) {
|
||||
- Object[] aobject = this.b;
|
||||
+ K[] aobject = this.b; // Paper - decompile fix
|
||||
int[] aint = this.c;
|
||||
|
||||
- this.b = (Object[]) (new Object[i]);
|
||||
+ this.b = (K[]) (new Object[i]); // Paper - decompile fix
|
||||
this.c = new int[i];
|
||||
- this.d = (Object[]) (new Object[i]);
|
||||
+ this.d = (K[]) (new Object[i]); // Paper - decompile fix
|
||||
this.e = 0;
|
||||
this.f = 0;
|
||||
+ this.usedIds.clear(); // Paper
|
||||
|
||||
for (int j = 0; j < aobject.length; ++j) {
|
||||
if (aobject[j] != null) {
|
||||
@@ -0,0 +0,0 @@ public class RegistryID<K> implements Registry<K> {
|
||||
}
|
||||
|
||||
public void a(K k0, int i) {
|
||||
- int j = Math.max(i, this.f + 1);
|
||||
+ int j = this.usedIds.size(); // Paper
|
||||
int k;
|
||||
|
||||
if ((float) j >= (float) this.b.length * 0.8F) {
|
||||
@@ -0,0 +0,0 @@ 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;
|
||||
@@ -0,0 +0,0 @@ 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.17.0 (Apple Git-106)
|
||||
|
Loading…
Reference in a new issue