78202f87b7
Speaking with Amaranth, his point of his implementation was that most of the lookups are on loaded chunks, so that code is optimized for that case. While Long2Object should be faster as a general purpose map, for MC uses, Amaranth's version should be faster. Will try to benchmark the 2 at some future.
33 lines
1.4 KiB
Diff
33 lines
1.4 KiB
Diff
From 4450f745a28e5709f5df9bb18e8347a47370301f Mon Sep 17 00:00:00 2001
|
|
From: Aikar <aikar@aikar.co>
|
|
Date: Wed, 30 Mar 2016 02:13:24 -0400
|
|
Subject: [PATCH] Use FastUtil Int HashMap for DataWatcher
|
|
|
|
For DataWatcher, swap out plain Integer key HashMap for a Int2ObjectOpenHashMap
|
|
|
|
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/DataWatcher.java b/src/main/java/net/minecraft/server/DataWatcher.java
|
|
index f1c62ec..68a0565 100644
|
|
--- a/src/main/java/net/minecraft/server/DataWatcher.java
|
|
+++ b/src/main/java/net/minecraft/server/DataWatcher.java
|
|
@@ -11,13 +11,14 @@ 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<Class<? extends Entity>, Integer> a = Maps.newHashMap();
|
|
private final Entity b;
|
|
- private final Map<Integer, DataWatcher.Item<?>> c = Maps.newHashMap();
|
|
+ private final Map<Integer, DataWatcher.Item<?>> c = new Int2ObjectOpenHashMap<>(); // Paper
|
|
private final ReadWriteLock d = new ReentrantReadWriteLock();
|
|
private boolean e = true;
|
|
private boolean f;
|
|
--
|
|
2.8.0
|
|
|