mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 20:07:41 +01:00
Fix issues with IntIdentityHashBiMiap
This commit is contained in:
parent
c03b8b99e3
commit
ddf004bd5e
@ -1,65 +0,0 @@
|
|||||||
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 IntIdentityHashBiMiap#nextId()
|
|
||||||
|
|
||||||
Optimizes CrudeIncrementalIntIdentityHashBiMap#nextId()
|
|
||||||
|
|
||||||
This is a frequent hotspot for world loading/saving.
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/util/CrudeIncrementalIntIdentityHashBiMap.java b/src/main/java/net/minecraft/util/CrudeIncrementalIntIdentityHashBiMap.java
|
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
||||||
--- a/src/main/java/net/minecraft/util/CrudeIncrementalIntIdentityHashBiMap.java
|
|
||||||
+++ b/src/main/java/net/minecraft/util/CrudeIncrementalIntIdentityHashBiMap.java
|
|
||||||
@@ -0,0 +0,0 @@ public class CrudeIncrementalIntIdentityHashBiMap<K> implements IdMap<K> {
|
|
||||||
private K[] byId;
|
|
||||||
private int nextId;
|
|
||||||
private int size;
|
|
||||||
+ private java.util.BitSet usedIds; // Paper
|
|
||||||
|
|
||||||
private CrudeIncrementalIntIdentityHashBiMap(int size) {
|
|
||||||
this.keys = (K[])(new Object[size]);
|
|
||||||
this.values = new int[size];
|
|
||||||
this.byId = (K[])(new Object[size]);
|
|
||||||
+ this.usedIds = new java.util.BitSet(); // Paper
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <A> CrudeIncrementalIntIdentityHashBiMap<A> create(int expectedSize) {
|
|
||||||
@@ -0,0 +0,0 @@ public class CrudeIncrementalIntIdentityHashBiMap<K> implements IdMap<K> {
|
|
||||||
}
|
|
||||||
|
|
||||||
private int nextId() {
|
|
||||||
+ /* // Paper start
|
|
||||||
while(this.nextId < this.byId.length && this.byId[this.nextId] != null) {
|
|
||||||
++this.nextId;
|
|
||||||
}
|
|
||||||
+ */
|
|
||||||
+ this.nextId = this.usedIds.nextClearBit(0);
|
|
||||||
+ // Paper end
|
|
||||||
|
|
||||||
return this.nextId;
|
|
||||||
}
|
|
||||||
@@ -0,0 +0,0 @@ public class CrudeIncrementalIntIdentityHashBiMap<K> implements IdMap<K> {
|
|
||||||
this.byId = crudeIncrementalIntIdentityHashBiMap.byId;
|
|
||||||
this.nextId = crudeIncrementalIntIdentityHashBiMap.nextId;
|
|
||||||
this.size = crudeIncrementalIntIdentityHashBiMap.size;
|
|
||||||
+ this.usedIds.clear(); // Paper
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addMapping(K value, int id) {
|
|
||||||
@@ -0,0 +0,0 @@ public class CrudeIncrementalIntIdentityHashBiMap<K> implements IdMap<K> {
|
|
||||||
this.keys[k] = value;
|
|
||||||
this.values[k] = id;
|
|
||||||
this.byId[id] = value;
|
|
||||||
+ this.usedIds.set(id); // Paper
|
|
||||||
++this.size;
|
|
||||||
if (id == this.nextId) {
|
|
||||||
++this.nextId;
|
|
||||||
@@ -0,0 +0,0 @@ public class CrudeIncrementalIntIdentityHashBiMap<K> implements IdMap<K> {
|
|
||||||
Arrays.fill(this.byId, (Object)null);
|
|
||||||
this.nextId = 0;
|
|
||||||
this.size = 0;
|
|
||||||
+ this.usedIds.clear(); // Paper
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
Loading…
Reference in New Issue
Block a user