now using ThreadMapUtil for temp array during saving

This commit is contained in:
cola98765
2021-09-20 12:50:49 +02:00
parent 25fd29b97e
commit 1156b7dd28
3 changed files with 11 additions and 3 deletions
@@ -137,7 +137,7 @@ public class SingleLevelContainer implements LevelContainer
{
int index = 0;
int tempIndex;
byte[] tempData = new byte[1 + (size * size * 8)];
byte[] tempData = ThreadMapUtil.getSaveContainer(1 + (size * size * 8));
tempData[index] = detailLevel;
index++;
for (int x = 0; x < size; x++)
@@ -152,7 +152,7 @@ public class VerticalLevelContainer implements LevelContainer
{
int index = 0;
int tempIndex;
byte[] tempData = new byte[2 + (size * size * maxVerticalData * 8)];
byte[] tempData = ThreadMapUtil.getSaveContainer(2 + (size * size * maxVerticalData * 8));
tempData[index] = detailLevel;
index++;
tempData[index] = (byte) maxVerticalData;
@@ -19,7 +19,7 @@ public class ThreadMapUtil
public static final ConcurrentMap<String, long[]> threadAdjData = new ConcurrentHashMap<>();
public static final ConcurrentMap<String, byte[]> saveContainer = new ConcurrentHashMap<>();
public static final ConcurrentMap<String, short[]> projectionShortMap = new ConcurrentHashMap<>();
public static final ConcurrentMap<String, short[]> heightAndDepthMap = new ConcurrentHashMap<>();
public static final ConcurrentMap<String, long[]> singleDataToMergeMap = new ConcurrentHashMap<>();
@@ -131,6 +131,14 @@ public class ThreadMapUtil
return heightAndDepthMap.get(Thread.currentThread().getName());
}
public static byte[] getSaveContainer(int size){
if(!saveContainer.containsKey(Thread.currentThread().getName()) || (saveContainer.get(Thread.currentThread().getName()) == null) || (saveContainer.get(Thread.currentThread().getName()).length != size))
{
saveContainer.put(Thread.currentThread().getName(), new byte[size]);
}
return saveContainer.get(Thread.currentThread().getName());
}
public static long[] getSingleAddDataToMerge(int size){
if(!singleDataToMergeMap.containsKey(Thread.currentThread().getName()) || (singleDataToMergeMap.get(Thread.currentThread().getName()) == null) || (singleDataToMergeMap.get(Thread.currentThread().getName()).length != size))
{