From a553961c05df12693a625f46e0587e0bc3e7c44b Mon Sep 17 00:00:00 2001 From: Jordan Date: Sat, 27 May 2023 13:25:07 +0100 Subject: [PATCH] refactor: switch to EnumSet for heightmaps to improve performance (#2248) --- .../java/com/fastasyncworldedit/core/queue/IChunkSet.java | 4 ++-- .../core/queue/implementation/blocks/CharSetBlocks.java | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/IChunkSet.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/IChunkSet.java index 79aed9f23..6d1f5c430 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/IChunkSet.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/IChunkSet.java @@ -9,7 +9,7 @@ import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BlockStateHolder; import javax.annotation.Nullable; -import java.util.HashMap; +import java.util.EnumMap; import java.util.Map; import java.util.Set; import java.util.UUID; @@ -95,7 +95,7 @@ public interface IChunkSet extends IBlocks, OutputExtent { } default Map getHeightMaps() { - return new HashMap<>(); + return new EnumMap<>(HeightMapType.class); } @Override diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/blocks/CharSetBlocks.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/blocks/CharSetBlocks.java index 291a3cf57..6f5129f4f 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/blocks/CharSetBlocks.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/blocks/CharSetBlocks.java @@ -15,7 +15,7 @@ import com.sk89q.worldedit.world.block.BlockTypesCache; import java.util.Arrays; import java.util.Collections; -import java.util.HashMap; +import java.util.EnumMap; import java.util.HashSet; import java.util.Map; import java.util.Set; @@ -40,7 +40,7 @@ public class CharSetBlocks extends CharBlocks implements IChunkSet { public BlockVector3ChunkMap tiles; public HashSet entities; public HashSet entityRemoves; - public Map heightMaps; + public EnumMap heightMaps; private boolean fastMode = false; private int bitMask = -1; @@ -93,7 +93,7 @@ public class CharSetBlocks extends CharBlocks implements IChunkSet { @Override public Map getHeightMaps() { - return heightMaps == null ? new HashMap<>() : heightMaps; + return heightMaps == null ? new EnumMap<>(HeightMapType.class) : heightMaps; } @Override @@ -177,7 +177,7 @@ public class CharSetBlocks extends CharBlocks implements IChunkSet { @Override public void setHeightMap(HeightMapType type, int[] heightMap) { if (heightMaps == null) { - heightMaps = new HashMap<>(); + heightMaps = new EnumMap<>(HeightMapType.class); } heightMaps.put(type, heightMap); }