mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-26 02:57:37 +01:00
Less line
Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
parent
5e41b148a4
commit
379ca22903
@ -141,29 +141,23 @@ final class PaletteImpl implements Palette, Cloneable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fill(int value) {
|
public void fill(int value) {
|
||||||
final boolean placedAir = value == 0;
|
if (value == 0) {
|
||||||
if (!placedAir) value = getPaletteIndex(value);
|
this.values = new long[0];
|
||||||
|
this.count = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
value = getPaletteIndex(value);
|
||||||
final int bitsPerEntry = this.bitsPerEntry;
|
final int bitsPerEntry = this.bitsPerEntry;
|
||||||
final int valuesPerLong = VALUES_PER_LONG[bitsPerEntry];
|
final int valuesPerLong = VALUES_PER_LONG[bitsPerEntry];
|
||||||
long[] values = this.values;
|
long[] values = this.values;
|
||||||
if (values.length == 0) {
|
if (values.length == 0) {
|
||||||
if (placedAir) {
|
|
||||||
// Section is empty and method is trying to place an air block, stop unnecessary computation
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// Initialize the section
|
|
||||||
this.values = values = new long[(size + valuesPerLong - 1) / valuesPerLong];
|
this.values = values = new long[(size + valuesPerLong - 1) / valuesPerLong];
|
||||||
}
|
}
|
||||||
if (placedAir) {
|
long block = 0;
|
||||||
this.values = new long[0];
|
for (int i = 0; i < valuesPerLong; i++)
|
||||||
this.count = 0;
|
block |= (long) value << i * bitsPerEntry;
|
||||||
} else {
|
Arrays.fill(values, block);
|
||||||
long block = 0;
|
this.count = maxSize();
|
||||||
for (int i = 0; i < valuesPerLong; i++)
|
|
||||||
block |= (long) value << i * bitsPerEntry;
|
|
||||||
Arrays.fill(values, block);
|
|
||||||
this.count = maxSize();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user