From 37381896bc5b79bd4c8cf2b1980d87305e66abfd Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sat, 20 Apr 2024 11:38:31 -0500 Subject: [PATCH] Fix warnings about updating empty maps --- .../core/dataObjects/fullData/FullDataPointIdMap.java | 2 +- .../dataObjects/fullData/sources/FullDataSourceV2.java | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/FullDataPointIdMap.java b/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/FullDataPointIdMap.java index 4dd9ef5b9..ce362a4e6 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/FullDataPointIdMap.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/FullDataPointIdMap.java @@ -61,7 +61,6 @@ public class FullDataPointIdMap private static final String BLOCK_STATE_SEPARATOR_STRING = "_DH-BSW_"; - // FIXME: Improve performance maybe? /** used when the data point map is running normally */ private final ReentrantReadWriteLock readWriteLock = new ReentrantReadWriteLock(); @@ -118,6 +117,7 @@ public class FullDataPointIdMap /** @return -1 if the list is empty */ public int getMaxValidId() { return this.entryList.size() - 1; } + public boolean isEmpty() { return this.entryList.isEmpty(); } public DhSectionPos getPos() { return this.pos; } diff --git a/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/sources/FullDataSourceV2.java b/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/sources/FullDataSourceV2.java index 1fd66bb9d..2282ac0df 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/sources/FullDataSourceV2.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/sources/FullDataSourceV2.java @@ -223,6 +223,13 @@ public class FullDataSourceV2 implements IDataSource public boolean update(@NotNull FullDataSourceV2 inputDataSource, @Nullable IDhLevel level) { return this.update(inputDataSource); } public boolean update(@NotNull FullDataSourceV2 inputDataSource) { + // don't try updating if the input is empty + if (inputDataSource.mapping.isEmpty()) + { + return false; + } + + byte thisDetailLevel = this.pos.getDetailLevel(); byte inputDetailLevel = inputDataSource.pos.getDetailLevel();