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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/level/ChunkHolder.java +++ b/src/main/java/net/minecraft/server/level/ChunkHolder.java @@ -0,0 +0,0 @@ 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); @@ -0,0 +0,0 @@ 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));