From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Paul Sauve <paul@technove.co>
Date: Sat, 13 Mar 2021 10:19:15 -0600
Subject: [PATCH] Skip copying unloading tile entities


diff --git a/src/main/java/net/minecraft/world/level/World.java b/src/main/java/net/minecraft/world/level/World.java
index 3e08e56f67516333e7d880fdc595447a3ae4dc83..f0420b87025a090a659542a00614e805bf850fd2 100644
--- a/src/main/java/net/minecraft/world/level/World.java
+++ b/src/main/java/net/minecraft/world/level/World.java
@@ -106,7 +106,7 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
     //public final List<TileEntity> tileEntityList = Lists.newArrayList(); // Paper - remove unused list
     public final List<TileEntity> tileEntityListTick = Lists.newArrayList();
     protected final List<TileEntity> tileEntityListPending = Lists.newArrayList();
-    protected final java.util.Set<TileEntity> tileEntityListUnload = com.google.common.collect.Sets.newHashSet();
+    protected final java.util.Set<TileEntity> tileEntityListUnload = java.util.Collections.newSetFromMap(new java.util.IdentityHashMap<>()); // Airplane - use set with faster contains
     public final Thread serverThread;
     private final boolean debugWorld;
     private int d;
@@ -986,12 +986,17 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
         gameprofilerfiller.enter("blockEntities");
         timings.tileEntityTick.startTiming(); // Spigot
         if (!this.tileEntityListUnload.isEmpty()) {
+            // Airplane start - we just use the identitymap as the basis for the unload set now instead of copying
+            /*
             // Paper start - Use alternate implementation with faster contains
             java.util.Set<TileEntity> toRemove = java.util.Collections.newSetFromMap(new java.util.IdentityHashMap<>());
             toRemove.addAll(tileEntityListUnload);
             this.tileEntityListTick.removeAll(toRemove);
             // Paper end
             //this.tileEntityList.removeAll(this.tileEntityListUnload); // Paper - remove unused list
+             */
+            this.tileEntityListTick.removeAll(this.tileEntityListUnload);
+            // Airplane end
             this.tileEntityListUnload.clear();
         }
 
