From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Spottedleaf 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 326aecc38a7f93fe0d25fb9b772d06f78f99781d..df33755f0196399a32cdbc993272e74919aa3f44 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 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));