More unnecessary null checks

This commit is contained in:
Matt Nadareski
2025-01-10 22:03:50 -05:00
parent 20ec4edeb8
commit b869b324bb
3 changed files with 5 additions and 9 deletions

View File

@@ -15,7 +15,7 @@ namespace SabreTools.DatFiles
public Models.Metadata.MetadataFile? ConvertToMetadata(bool ignoreblanks = false)
{
// If we don't have items, we can't do anything
if (Items == null || Items.Count == 0)
if (Items.Count == 0)
return null;
// Create an object to hold the data
@@ -40,7 +40,7 @@ namespace SabreTools.DatFiles
public Models.Metadata.MetadataFile? ConvertToMetadataDB(bool ignoreblanks = false)
{
// If we don't have items, we can't do anything
if (ItemsDB == null)
if (ItemsDB.GetItems().Count == 0)
return null;
// Create an object to hold the data
@@ -64,10 +64,6 @@ namespace SabreTools.DatFiles
/// </summary>
private Models.Metadata.Header? ConvertHeader()
{
// If the header is invalid, we can't do anything
if (Header == null)
return null;
// Create an internal header
var header = Header.GetInternalClone();

View File

@@ -87,7 +87,7 @@ namespace SabreTools.DatTools
public bool ApplyExtras(DatFile datFile, bool throwOnError = false)
{
// If we have no extras, don't attempt to apply and just return true
if (Items == null || Items.Count == 0)
if (Items.Count == 0)
return true;
var watch = new InternalStopwatch("Applying extra mappings to DAT");
@@ -150,7 +150,7 @@ namespace SabreTools.DatTools
public bool ApplyExtrasDB(DatFile datFile, bool throwOnError = false)
{
// If we have no extras, don't attempt to apply and just return true
if (Items == null || Items.Count == 0)
if (Items.Count == 0)
return true;
var watch = new InternalStopwatch("Applying extra mappings to DAT");

View File

@@ -134,7 +134,7 @@ namespace SabreTools.DatTools
public void SetFields(DatHeader datHeader)
{
// If we have an invalid input, return
if (datHeader == null || HeaderFieldMappings.Count == 0)
if (HeaderFieldMappings.Count == 0)
return;
foreach (var kvp in HeaderFieldMappings)