Yatopia/patches/Airplane/patches/server/0018-Skip-copying-unloading...

38 lines
2.2 KiB
Diff

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 726d0aec2c40ac8e40dba3a12f17870abae6dca6..334281d4cbdb2d82ca93e862498af961d9abfd31 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;
@@ -993,12 +993,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();
}