Fix warnings about updating empty maps

This commit is contained in:
James Seibel
2024-04-20 11:38:31 -05:00
parent 22f4757aae
commit 37381896bc
2 changed files with 8 additions and 1 deletions
@@ -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; }
@@ -223,6 +223,13 @@ public class FullDataSourceV2 implements IDataSource<IDhLevel>
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();