From 0148ad9aaf03857da4060ee535ad18ce77b82614 Mon Sep 17 00:00:00 2001 From: themode Date: Tue, 4 Jan 2022 06:07:24 +0100 Subject: [PATCH] Optimize palette clear --- .../server/instance/palette/PaletteImpl.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main/java/net/minestom/server/instance/palette/PaletteImpl.java b/src/main/java/net/minestom/server/instance/palette/PaletteImpl.java index 57605049e..4810f4372 100644 --- a/src/main/java/net/minestom/server/instance/palette/PaletteImpl.java +++ b/src/main/java/net/minestom/server/instance/palette/PaletteImpl.java @@ -154,12 +154,17 @@ final class PaletteImpl implements Palette, Cloneable { this.values = values = new long[(size + valuesPerLong - 1) / valuesPerLong]; } - long block = 0; - for (int i = 0; i < valuesPerLong; i++) { - block |= (long) value << i * bitsPerEntry; + if (placedAir) { + Arrays.fill(values, 0); + this.count = 0; + } else { + long block = 0; + for (int i = 0; i < valuesPerLong; i++) { + block |= (long) value << i * bitsPerEntry; + } + Arrays.fill(values, block); + this.count = maxSize(); } - Arrays.fill(values, block); - this.count = placedAir ? 0 : maxSize(); } @Override