31 Zeilen
1.6 KiB
Diff
31 Zeilen
1.6 KiB
Diff
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||
|
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
||
|
Date: Thu, 11 Mar 2021 21:17:02 -0800
|
||
|
Subject: [PATCH] Use hash table for maintaing changed block set
|
||
|
|
||
|
When a lot of block changes occur the iteration for checking can
|
||
|
add up a bit and cause a small performance impact.
|
||
|
|
||
|
diff --git a/src/main/java/net/minecraft/server/level/ChunkHolder.java b/src/main/java/net/minecraft/server/level/ChunkHolder.java
|
||
|
index 234a1eff2d664bf611c5337ee84d091b64cd7004..54cb9f909df7d1041cec553e1f54ff8ecff48bbe 100644
|
||
|
--- a/src/main/java/net/minecraft/server/level/ChunkHolder.java
|
||
|
+++ b/src/main/java/net/minecraft/server/level/ChunkHolder.java
|
||
|
@@ -41,6 +41,8 @@ import net.minecraft.world.level.lighting.LevelLightEngine;
|
||
|
import net.minecraft.server.MinecraftServer;
|
||
|
// CraftBukkit end
|
||
|
|
||
|
+import it.unimi.dsi.fastutil.shorts.ShortOpenHashSet; // Paper
|
||
|
+
|
||
|
public class ChunkHolder {
|
||
|
|
||
|
public static final Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure> UNLOADED_CHUNK = Either.right(ChunkHolder.ChunkLoadingFailure.UNLOADED);
|
||
|
@@ -390,7 +392,7 @@ public class ChunkHolder {
|
||
|
if (i < 0 || i >= this.changedBlocksPerSection.length) return; // CraftBukkit - SPIGOT-6086, SPIGOT-6296
|
||
|
if (this.changedBlocksPerSection[i] == null) {
|
||
|
this.hasChangedSections = true;
|
||
|
- this.changedBlocksPerSection[i] = new ShortArraySet();
|
||
|
+ this.changedBlocksPerSection[i] = new ShortOpenHashSet(); // Paper - use a set to make setting constant-time
|
||
|
}
|
||
|
|
||
|
this.changedBlocksPerSection[i].add(SectionPos.sectionRelativePos(pos));
|