aboutsummaryrefslogtreecommitdiffhomepage
path: root/Spigot-Server-Patches/0100-Use-Optimized-Collections.patch
blob: 44fc35b3bbb03adec1f49437576dc7468c48eb7f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
From bf55746ae8469ec426c19372f7fd267fc13b976e Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Wed, 30 Mar 2016 02:13:24 -0400
Subject: [PATCH] Use Optimized Collections

Swap out CraftBukkit LongObjectHashMap with Long2ObjectOpenHashMap
Swap out Integer key HashMap for a Int2ObjectOpenHashMap For ChunkProviderServer

Amaranth, the creator of LongObjectHashMap, tested it vs fastutil and determined fastutil to be 3x faster
and could not create anything faster than fastutil.

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 b49f4e292..dd37bec73 100644
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
@@ -24,7 +24,7 @@ import org.bukkit.event.world.ChunkUnloadEvent;
 public class ChunkProviderServer implements IChunkProvider {
 
     private static final Logger a = LogManager.getLogger();
-    public final Set<Long> unloadQueue = Sets.newHashSet();
+    public final it.unimi.dsi.fastutil.longs.LongSet unloadQueue = new it.unimi.dsi.fastutil.longs.LongArraySet(); // PAIL: private -> public // Paper
     public final ChunkGenerator chunkGenerator;
     private final IChunkLoader chunkLoader;
     // Paper start
diff --git a/src/main/java/net/minecraft/server/DataWatcher.java b/src/main/java/net/minecraft/server/DataWatcher.java
index 419add5db..820c15278 100644
--- a/src/main/java/net/minecraft/server/DataWatcher.java
+++ b/src/main/java/net/minecraft/server/DataWatcher.java
@@ -12,6 +12,7 @@ import java.util.Map;
 import java.util.concurrent.locks.ReadWriteLock;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
 import javax.annotation.Nullable;
+import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; // Paper
 import org.apache.commons.lang3.ObjectUtils;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
@@ -21,7 +22,7 @@ public class DataWatcher {
     private static final Logger a = LogManager.getLogger();
     private static final Map<Class<? extends Entity>, Integer> b = Maps.newHashMap();
     private final Entity c;
-    private final Map<Integer, DataWatcher.Item<?>> d = Maps.newHashMap();
+    private final Map<Integer, DataWatcher.Item<?>> d = new Int2ObjectOpenHashMap<>(); // Paper
     private final ReadWriteLock e = new ReentrantReadWriteLock();
     private boolean f = true;
     private boolean g;
-- 
2.12.2.windows.2