aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJoseph Hirschfeld <[email protected]>2016-02-20 21:34:29 -0600
committerZach Brown <[email protected]>2016-02-20 21:34:45 -0600
commita861cc6d8c6d15f3cb2d87522fb73dc1deb46f65 (patch)
tree383a9158f5976a43826aa6ebe3ade6726ba0cd90
parent1d78a73b5d2ada0c21d47b27227831cb0960576e (diff)
downloadPaper-a861cc6d8c6d15f3cb2d87522fb73dc1deb46f65.tar.gz
Paper-a861cc6d8c6d15f3cb2d87522fb73dc1deb46f65.zip
Change implementation of tile entity removal list
-rw-r--r--Spigot-Server-Patches/0096-Change-implementation-of-tile-entity-removal-list.patch65
1 files changed, 65 insertions, 0 deletions
diff --git a/Spigot-Server-Patches/0096-Change-implementation-of-tile-entity-removal-list.patch b/Spigot-Server-Patches/0096-Change-implementation-of-tile-entity-removal-list.patch
new file mode 100644
index 0000000000..05453cb2d0
--- /dev/null
+++ b/Spigot-Server-Patches/0096-Change-implementation-of-tile-entity-removal-list.patch
@@ -0,0 +1,65 @@
+From 3cd83fe77b1f1c37592895e602d2c4588aa9cbdc Mon Sep 17 00:00:00 2001
+From: Joseph Hirschfeld <[email protected]>
+Date: Sat, 20 Feb 2016 00:42:18 -0500
+Subject: [PATCH] Change implementation of (tile)entity removal list
+
+As it stood, the complexity of a ArrayList.removeAll(ArrayList) is
+much greater as the argument array list grew than .removeAll(HashSet).
+
+diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
+index a76d83c..f0cd810 100644
+--- a/src/main/java/net/minecraft/server/World.java
++++ b/src/main/java/net/minecraft/server/World.java
+@@ -3,6 +3,7 @@ package net.minecraft.server;
+ import com.google.common.base.Predicate;
+ import com.google.common.collect.Lists;
+ import com.google.common.collect.Maps;
++import com.google.common.collect.Sets;
+ import org.bukkit.Bukkit;
+ import org.bukkit.block.BlockState;
+ import org.bukkit.craftbukkit.CraftServer;
+@@ -58,11 +59,11 @@ public abstract class World implements IBlockAccess {
+ }
+ };
+ // Spigot end
+- protected final List<Entity> g = Lists.newArrayList();
++ protected final Set<Entity> g = Sets.newHashSet(); // Paper
+ //public final List<TileEntity> h = Lists.newArrayList(); // PaperSpigot - Remove unused list
+ public final List<TileEntity> tileEntityList = Lists.newArrayList();
+ private final List<TileEntity> b = Lists.newArrayList();
+- private final List<TileEntity> c = Lists.newArrayList();
++ private final Set<TileEntity> c = Sets.newHashSet(); // Paper
+ public final List<EntityHuman> players = Lists.newArrayList();
+ public final List<Entity> k = Lists.newArrayList();
+ protected final IntHashMap<Entity> entitiesById = new IntHashMap();
+@@ -1400,18 +1401,19 @@ public abstract class World implements IBlockAccess {
+ int j;
+ int k;
+
+- for (i = 0; i < this.g.size(); ++i) {
+- entity = (Entity) this.g.get(i);
+- j = entity.ae;
+- k = entity.ag;
+- if (entity.ad && this.isChunkLoaded(j, k, true)) {
+- this.getChunkAt(j, k).b(entity);
++ // Paper start - Set based removal lists
++ for (Entity e : this.g) {
++ j = e.ae;
++ k = e.ag;
++ if (e.ad && this.isChunkLoaded(j, k, true)) {
++ this.getChunkAt(j, k).b(e);
+ }
+ }
+
+- for (i = 0; i < this.g.size(); ++i) {
+- this.b((Entity) this.g.get(i));
++ for (Entity e : this.g) {
++ this.b(e);
+ }
++ // Paper end
+
+ this.g.clear();
+ timings.entityRemoval.stopTiming(); // Spigot
+--
+2.7.1
+