summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormd_5 <git@md-5.net>2018-11-04 11:40:15 +1100
committermd_5 <git@md-5.net>2018-11-04 11:40:15 +1100
commite693496c17562b3e865b545f755562bcad81f2e8 (patch)
tree60c1ddbcb3fbdc2b8ea26029a5261dc32fe5a4c5
parentf0398e444e43a9c63249e668eb85f5fecbb4b6db (diff)
downloadcraftbukkit-e693496c17562b3e865b545f755562bcad81f2e8.tar
craftbukkit-e693496c17562b3e865b545f755562bcad81f2e8.tar.gz
craftbukkit-e693496c17562b3e865b545f755562bcad81f2e8.tar.lz
craftbukkit-e693496c17562b3e865b545f755562bcad81f2e8.tar.xz
craftbukkit-e693496c17562b3e865b545f755562bcad81f2e8.zip
SPIGOT-4467: Improve ExpiringMap
-rw-r--r--nms-patches/ExpiringMap.patch61
1 files changed, 61 insertions, 0 deletions
diff --git a/nms-patches/ExpiringMap.patch b/nms-patches/ExpiringMap.patch
new file mode 100644
index 00000000..874be687
--- /dev/null
+++ b/nms-patches/ExpiringMap.patch
@@ -0,0 +1,61 @@
+--- a/net/minecraft/server/ExpiringMap.java
++++ b/net/minecraft/server/ExpiringMap.java
+@@ -4,8 +4,10 @@
+ import it.unimi.dsi.fastutil.longs.Long2LongMap;
+ import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
+ import it.unimi.dsi.fastutil.longs.Long2LongMap.Entry;
++import it.unimi.dsi.fastutil.objects.ObjectCollection;
+ import it.unimi.dsi.fastutil.objects.ObjectIterator;
+ import java.util.Map;
++import java.util.function.LongFunction;
+
+ public class ExpiringMap<T> extends Long2ObjectOpenHashMap<T> {
+
+@@ -21,11 +23,17 @@
+ long j = SystemUtils.b();
+
+ this.b.put(i, j);
+- ObjectIterator objectiterator = this.b.long2LongEntrySet().iterator();
++ cleanup();
++ // CraftBukkit start
++ }
++
++ public void cleanup() {
++ long j = SystemUtils.b();
++ ObjectIterator<Long2LongMap.Entry> objectiterator = this.b.long2LongEntrySet().iterator(); // CraftBukkit - decompile error
+
+ while (objectiterator.hasNext()) {
+- Entry entry = (Entry) objectiterator.next();
+- Object object = super.get(entry.getLongKey());
++ Long2LongMap.Entry entry = (Long2LongMap.Entry) objectiterator.next(); // CraftBukkit - decompile error
++ T object = super.get(entry.getLongKey()); // CraftBukkit - decompile error
+
+ if (j - entry.getLongValue() <= (long) this.a) {
+ break;
+@@ -36,6 +44,7 @@
+ objectiterator.remove();
+ }
+ }
++ // CraftBukkit end
+
+ }
+
+@@ -69,4 +78,18 @@
+ public T remove(Object object) {
+ throw new RuntimeException("Not implemented");
+ }
++
++ // CraftBukkit start
++ @Override
++ public T computeIfAbsent(long l, LongFunction<? extends T> lf) {
++ this.b.put(l, SystemUtils.b());
++ return super.computeIfAbsent(l, lf);
++ }
++
++ @Override
++ public ObjectCollection<T> values() {
++ cleanup();
++ return super.values();
++ }
++ // CraftBukkit end
+ }