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 de0c6316c9b75a2ecc7d6abf7bcca24e25de0ac0..4588ae8037407b81c99135863eb0c4e97c564c24 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));