9
0
mirror of https://github.com/VolmitSoftware/Iris.git synced 2025-12-19 15:09:18 +00:00

fix linear palette not growing correctly

This commit is contained in:
Julian Krings
2025-11-06 14:41:39 +01:00
parent 4ca7ea3911
commit 1d7cba184c
2 changed files with 4 additions and 4 deletions

View File

@@ -29,7 +29,7 @@ public class DataContainer<T> {
private static final boolean TRIM = Boolean.getBoolean("iris.trim-palette");
protected static final int INITIAL_BITS = 3;
protected static final int LINEAR_BITS_LIMIT = 4;
protected static final int LINEAR_INITIAL_LENGTH = (int) Math.pow(2, LINEAR_BITS_LIMIT) + 1;
protected static final int LINEAR_INITIAL_LENGTH = (int) Math.pow(2, LINEAR_BITS_LIMIT) + 2;
protected static final int[] BIT = computeBitLimits();
private final Lock read, write;

View File

@@ -52,11 +52,11 @@ public class LinearPalette<T> implements Palette<T> {
return index;
}
private synchronized void grow(int newLength) {
if (palette.length() <= newLength)
private synchronized void grow(int lastIndex) {
if (palette.length() > lastIndex)
return;
AtomicReferenceArray<T> a = new AtomicReferenceArray<>(newLength + 1);
AtomicReferenceArray<T> a = new AtomicReferenceArray<>(lastIndex + 1);
for (int i = 0; i < palette.length(); i++) {
a.set(i, palette.get(i));
}