-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
145 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: Mechoriet <[email protected]> | ||
Date: Sat, 7 Oct 2023 21:24:34 +0200 | ||
Subject: [PATCH] fixup! fastutil - NBTTagCompound | ||
|
||
|
||
diff --git a/src/main/java/net/minecraft/server/NBTTagCompound.java b/src/main/java/net/minecraft/server/NBTTagCompound.java | ||
index 89c9298fde1711a1a5923b81715f45f1341fa693..01cc42ebc8429ac0fb66366542781739fbe77ee7 100644 | ||
--- a/src/main/java/net/minecraft/server/NBTTagCompound.java | ||
+++ b/src/main/java/net/minecraft/server/NBTTagCompound.java | ||
@@ -12,10 +12,14 @@ import java.util.concurrent.Callable; | ||
|
||
public class NBTTagCompound extends NBTBase { | ||
|
||
- private Map<String, NBTBase> map = new it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap<>(8, 0.8f); // PandaSpigot - reduce memory footprint of NBTTagCompound | ||
- | ||
- public NBTTagCompound() {} | ||
+ private Map<String, NBTBase> map; | ||
|
||
+ public NBTTagCompound() { | ||
+ map = new it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap<>(8, 0.8f); // PandaSpigot - reduce memory footprint of NBTTagCompound | ||
+ } | ||
+ public NBTTagCompound(it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap<String, NBTBase> map) { | ||
+ this.map = map; | ||
+ } | ||
void write(DataOutput dataoutput) throws IOException { | ||
Iterator iterator = this.map.keySet().iterator(); | ||
|
||
@@ -282,16 +286,17 @@ public class NBTTagCompound extends NBTBase { | ||
} | ||
|
||
public NBTBase clone() { | ||
- NBTTagCompound nbttagcompound = new NBTTagCompound(); | ||
- Iterator iterator = this.map.keySet().iterator(); | ||
- | ||
+ it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap<String, NBTBase> ret = new it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap<>( | ||
+ this.map.size(), 0.8f); | ||
+ Iterator<Map.Entry<String, NBTBase>> iterator = (this.map instanceof it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap) | ||
+ ? ((it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap) this.map).object2ObjectEntrySet() | ||
+ .fastIterator() | ||
+ : this.map.entrySet().iterator(); | ||
while (iterator.hasNext()) { | ||
- String s = (String) iterator.next(); | ||
- | ||
- nbttagcompound.set(s, ((NBTBase) this.map.get(s)).clone()); | ||
+ Map.Entry<String, NBTBase> entry = iterator.next(); | ||
+ ret.put(entry.getKey(), entry.getValue().clone()); | ||
} | ||
- | ||
- return nbttagcompound; | ||
+ return new NBTTagCompound(ret); | ||
} | ||
|
||
public boolean equals(Object object) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: Mechoriet <[email protected]> | ||
Date: Sat, 7 Oct 2023 21:29:31 +0200 | ||
Subject: [PATCH] fastutil - DataWatcher | ||
|
||
|
||
diff --git a/src/main/java/net/minecraft/server/DataWatcher.java b/src/main/java/net/minecraft/server/DataWatcher.java | ||
index 518e8f379d690b1f1b4d2374c875dd3dae22360e..42909eddbb1984966d910cab2c3e3889472f4749 100644 | ||
--- a/src/main/java/net/minecraft/server/DataWatcher.java | ||
+++ b/src/main/java/net/minecraft/server/DataWatcher.java | ||
@@ -16,11 +16,11 @@ public class DataWatcher { | ||
private final Entity a; | ||
private boolean b = true; | ||
// Spigot Start | ||
- private static final gnu.trove.map.TObjectIntMap classToId = new gnu.trove.map.hash.TObjectIntHashMap( 10, 0.5f, -1 ); | ||
- private final gnu.trove.map.TIntObjectMap dataValues = new gnu.trove.map.hash.TIntObjectHashMap( 10, 0.5f, -1 ); | ||
+ private static final it.unimi.dsi.fastutil.objects.Object2IntMap<Class<?>> classToId = new it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap<>(10, 0.5f); | ||
+ private final it.unimi.dsi.fastutil.ints.Int2ObjectMap dataValues = new it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap<>( 10, 0.5f); | ||
// These exist as an attempt at backwards compatability for (broken) NMS plugins | ||
- private static final Map<Class<?>, Integer> c = gnu.trove.TDecorators.wrap( classToId ); | ||
- private final Map<Integer, DataWatcher.WatchableObject> d = gnu.trove.TDecorators.wrap( dataValues ); | ||
+ private static final Map<Class<?>, Integer> c = classToId; | ||
+ private final Map<Integer, DataWatcher.WatchableObject> d = dataValues; | ||
// Spigot End | ||
private boolean e; | ||
// private ReadWriteLock f = new ReentrantReadWriteLock(); // PandaSpigot - Remove DataWatcher Locking | ||
@@ -151,7 +151,7 @@ public class DataWatcher { | ||
|
||
if (this.e) { | ||
// this.f.readLock().lock(); // PandaSpigot | ||
- Iterator iterator = this.dataValues.valueCollection().iterator(); // Spigot | ||
+ Iterator iterator = this.dataValues.values().iterator(); // Spigot | ||
|
||
while (iterator.hasNext()) { | ||
DataWatcher.WatchableObject datawatcher_watchableobject = (DataWatcher.WatchableObject) iterator.next(); | ||
@@ -186,7 +186,7 @@ public class DataWatcher { | ||
|
||
public void a(PacketDataSerializer packetdataserializer) throws IOException { | ||
// this.f.readLock().lock(); // PandaSpigot | ||
- Iterator iterator = this.dataValues.valueCollection().iterator(); // Spigot | ||
+ Iterator iterator = this.dataValues.values().iterator(); // Spigot | ||
|
||
while (iterator.hasNext()) { | ||
DataWatcher.WatchableObject datawatcher_watchableobject = (DataWatcher.WatchableObject) iterator.next(); | ||
@@ -203,7 +203,7 @@ public class DataWatcher { | ||
|
||
// this.f.readLock().lock(); // PandaSpigot | ||
|
||
- arraylist.addAll(this.dataValues.valueCollection()); // Spigot | ||
+ arraylist.addAll(this.dataValues.values()); // Spigot | ||
// Spigot start - copy ItemStacks to prevent ConcurrentModificationExceptions | ||
for ( int i = 0; i < arraylist.size(); i++ ) | ||
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: Mechoriet <[email protected]> | ||
Date: Sat, 7 Oct 2023 21:30:42 +0200 | ||
Subject: [PATCH] fastutil - HandshakeListener | ||
|
||
|
||
diff --git a/src/main/java/net/minecraft/server/HandshakeListener.java b/src/main/java/net/minecraft/server/HandshakeListener.java | ||
index 10a8c440f08535d90d8d1204a23c859ba296aa39..ef1a07a6d9667f7fd94f0f6596c4963ad5f0dd54 100644 | ||
--- a/src/main/java/net/minecraft/server/HandshakeListener.java | ||
+++ b/src/main/java/net/minecraft/server/HandshakeListener.java | ||
@@ -9,7 +9,7 @@ public class HandshakeListener implements PacketHandshakingInListener { | ||
|
||
private static final com.google.gson.Gson gson = new com.google.gson.Gson(); // Spigot | ||
// CraftBukkit start - add fields | ||
- private static final HashMap<InetAddress, Long> throttleTracker = new HashMap<InetAddress, Long>(); | ||
+ private static final java.util.Map<InetAddress, Long> throttleTracker = new it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap<>(); | ||
private static int throttleCounter = 0; | ||
// CraftBukkit end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: Mechoriet <[email protected]> | ||
Date: Sat, 7 Oct 2023 21:32:40 +0200 | ||
Subject: [PATCH] fastutil - ChunkProviderServer | ||
|
||
|
||
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java | ||
index 7085cb503db3e1e585417ce4300c6be075c7d2fe..079e8e29cc34e41eb932d6d90f8b775164a45251 100644 | ||
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java | ||
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java | ||
@@ -34,7 +34,7 @@ public class ChunkProviderServer implements IChunkProvider { | ||
public IChunkProvider chunkProvider; | ||
private IChunkLoader chunkLoader; | ||
public boolean forceChunkLoad = false; // CraftBukkit - true -> false | ||
- public LongObjectHashMap<Chunk> chunks = new LongObjectHashMap<Chunk>(); | ||
+ public it.unimi.dsi.fastutil.longs.Long2ObjectMap<Chunk> chunks = new it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap<>(4096, 0.5f); | ||
public WorldServer world; | ||
|
||
public ChunkProviderServer(WorldServer worldserver, IChunkLoader ichunkloader, IChunkProvider ichunkprovider) { |