diff --git a/Spigot-API-Patches/Add-minimal-fastutil-int-based-collections.patch b/Spigot-API-Patches/Add-minimal-fastutil-int-long-based-collections.patch similarity index 99% rename from Spigot-API-Patches/Add-minimal-fastutil-int-based-collections.patch rename to Spigot-API-Patches/Add-minimal-fastutil-int-long-based-collections.patch index 2ea4671501..66b9abd6c9 100644 --- a/Spigot-API-Patches/Add-minimal-fastutil-int-based-collections.patch +++ b/Spigot-API-Patches/Add-minimal-fastutil-int-long-based-collections.patch @@ -1,8 +1,10 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Aikar Date: Mon, 21 Mar 2016 18:17:14 -0400 -Subject: [PATCH] Add minimal fastutil int based collections +Subject: [PATCH] Add minimal fastutil int/long based collections +Importing entire FastUtil library would be massive. Just import minimal useful ones +we might actually use. diff --git a/src/main/java/it/unimi/dsi/fastutil/AbstractIndirectDoublePriorityQueue.java b/src/main/java/it/unimi/dsi/fastutil/AbstractIndirectDoublePriorityQueue.java new file mode 100644 diff --git a/Spigot-Server-Patches/Use-FastUtil-Long-Int-HashMap-s.patch b/Spigot-Server-Patches/Use-FastUtil-Long-Int-HashMap-s.patch new file mode 100644 index 0000000000..976c50ca28 --- /dev/null +++ b/Spigot-Server-Patches/Use-FastUtil-Long-Int-HashMap-s.patch @@ -0,0 +1,54 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Aikar +Date: Wed, 30 Mar 2016 02:13:24 -0400 +Subject: [PATCH] Use FastUtil Long/Int HashMap's + +For DataWatcher, swap out plain Integer key HashMap for a Int2ObjectOpenHashMap +For ChunkProviderServer, swap out CB's custom LongHashMap with Long2ObjectOpenHashMap + +These collections are super fast as seen +http://java-performance.info/hashmap-overview-jdk-fastutil-goldman-sachs-hppc-koloboke-trove-january-2015/ + +diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java ++++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java +@@ -0,0 +0,0 @@ import java.util.Iterator; + import java.util.List; + + import com.destroystokyo.paper.exception.ServerInternalException; ++import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; // Paper + import org.apache.logging.log4j.LogManager; + import org.apache.logging.log4j.Logger; + +@@ -0,0 +0,0 @@ public class ChunkProviderServer implements IChunkProvider { + private final IChunkLoader chunkLoader; + // Paper start + protected Chunk lastChunkByPos = null; +- public LongObjectHashMap chunks = new LongObjectHashMap() { ++ public Long2ObjectOpenHashMap chunks = new Long2ObjectOpenHashMap() { + @Override + public Chunk get(long key) { + if (lastChunkByPos != null && key == lastChunkByPos.chunkKey) { +diff --git a/src/main/java/net/minecraft/server/DataWatcher.java b/src/main/java/net/minecraft/server/DataWatcher.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/server/DataWatcher.java ++++ b/src/main/java/net/minecraft/server/DataWatcher.java +@@ -0,0 +0,0 @@ import java.util.List; + import java.util.Map; + import java.util.concurrent.locks.ReadWriteLock; + import java.util.concurrent.locks.ReentrantReadWriteLock; ++ ++import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; // Paper + import org.apache.commons.lang3.ObjectUtils; + + public class DataWatcher { + + private static final Map, Integer> a = Maps.newHashMap(); + private final Entity b; +- private final Map> c = Maps.newHashMap(); ++ private final Map> c = new Int2ObjectOpenHashMap<>(); // Paper + private final ReadWriteLock d = new ReentrantReadWriteLock(); + private boolean e = true; + private boolean f; +-- \ No newline at end of file