9
0
mirror of https://github.com/SparklyPower/SparklyPaper.git synced 2025-12-20 23:49:24 +00:00
Files
SparklyPaperMC/patches/server/0017-Skip-copying-unloading-tile-entities.patch
2021-03-15 08:05:40 -03:00

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/server/World.java b/src/main/java/net/minecraft/server/World.java
index 30ff822fb0d1a973feb8fa0a34d024608cbabbcf..996fa5b4652f847f4e64d4cd191fe5a597471afe 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -44,7 +44,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;
@@ -924,12 +924,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();
}