mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-26 10:01:36 +01:00
Improve getAll performance by 20%
This commit is contained in:
parent
59f12e1c26
commit
6827edb619
@ -99,16 +99,15 @@ final class PaletteImpl implements Palette, Cloneable {
|
||||
final int magicMask = MAGIC_MASKS[bitsPerEntry];
|
||||
final int valuesPerLong = VALUES_PER_LONG[bitsPerEntry];
|
||||
final int dimensionMinus = dimension - 1;
|
||||
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
final long value = values[i];
|
||||
for (int j = 0; j < valuesPerLong; j++) {
|
||||
final int index = i * valuesPerLong + j;
|
||||
final int startIndex = i * valuesPerLong;
|
||||
final int maxIndex = startIndex + valuesPerLong > size ? size - startIndex : valuesPerLong;
|
||||
for (int j = 0; j < maxIndex; j++) {
|
||||
final int index = startIndex + j;
|
||||
final int y = index >> (dimensionBitCount << 1);
|
||||
final int z = (index >> (dimensionBitCount)) & dimensionMinus;
|
||||
final int x = index & dimensionMinus;
|
||||
if (y >= dimension)
|
||||
return; // Out of bounds
|
||||
final int bitIndex = j * bitsPerEntry;
|
||||
final short paletteIndex = (short) (value >> bitIndex & magicMask);
|
||||
final int result = hasPalette ? paletteToValueList.getInt(paletteIndex) : paletteIndex;
|
||||
|
Loading…
Reference in New Issue
Block a user