diff --git a/Spigot-Server-Patches/Change-implementation-of-tile-entity-removal-list.patch b/Spigot-Server-Patches/Change-implementation-of-tile-entity-removal-list.patch new file mode 100644 index 0000000000..dc17c3a76c --- /dev/null +++ b/Spigot-Server-Patches/Change-implementation-of-tile-entity-removal-list.patch @@ -0,0 +1,63 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Joseph Hirschfeld +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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/server/World.java ++++ b/src/main/java/net/minecraft/server/World.java +@@ -0,0 +0,0 @@ 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; +@@ -0,0 +0,0 @@ public abstract class World implements IBlockAccess { + } + }; + // Spigot end +- protected final List g = Lists.newArrayList(); ++ protected final Set g = Sets.newHashSet(); // Paper + //public final List h = Lists.newArrayList(); // PaperSpigot - Remove unused list + public final List tileEntityList = Lists.newArrayList(); + private final List b = Lists.newArrayList(); +- private final List c = Lists.newArrayList(); ++ private final Set c = Sets.newHashSet(); // Paper + public final List players = Lists.newArrayList(); + public final List k = Lists.newArrayList(); + protected final IntHashMap entitiesById = new IntHashMap(); +@@ -0,0 +0,0 @@ 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 +-- \ No newline at end of file