mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Reduce nesting in comparison delegates
This commit is contained in:
@@ -439,33 +439,24 @@ namespace SabreTools.DatFiles
|
||||
int? ySourceIndex = y.Item2.GetFieldValue<Source?>(DatItem.SourceKey)?.Index;
|
||||
string? yType = y.Item2.GetStringFieldValue(Models.Metadata.DatItem.TypeKey);
|
||||
|
||||
// If machine names match, more refinement is needed
|
||||
if (xMachineName == yMachineName)
|
||||
{
|
||||
// If item types match, more refinement is needed
|
||||
if (xType == yType)
|
||||
{
|
||||
// If item directory names match, more refinement is needed
|
||||
if (xDirectoryName == yDirectoryName)
|
||||
{
|
||||
// If item names match, then compare on machine or source, depending on the flag
|
||||
if (xName == yName)
|
||||
return (norename ? nc.Compare(xMachineName, yMachineName) : (xSourceIndex - ySourceIndex) ?? 0);
|
||||
|
||||
// Otherwise, just sort based on item names
|
||||
return nc.Compare(xName, yName);
|
||||
}
|
||||
|
||||
// Otherwise, just sort based on directory name
|
||||
return nc.Compare(xDirectoryName, yDirectoryName);
|
||||
}
|
||||
|
||||
// Otherwise, just sort based on item type
|
||||
return xType.AsEnumValue<ItemType>() - yType.AsEnumValue<ItemType>();
|
||||
}
|
||||
|
||||
// Otherwise, just sort based on machine name
|
||||
// If machine names don't match
|
||||
if (xMachineName != yMachineName)
|
||||
return nc.Compare(xMachineName, yMachineName);
|
||||
|
||||
// If types don't match
|
||||
if (xType != yType)
|
||||
return xType.AsEnumValue<ItemType>() - yType.AsEnumValue<ItemType>();
|
||||
|
||||
// If directory names don't match
|
||||
if (xDirectoryName != yDirectoryName)
|
||||
return nc.Compare(xDirectoryName, yDirectoryName);
|
||||
|
||||
// If item names don't match
|
||||
if (xName != yName)
|
||||
return nc.Compare(xName, yName);
|
||||
|
||||
// Otherwise, compare on machine or source, depending on the flag
|
||||
return (norename ? nc.Compare(xMachineName, yMachineName) : (xSourceIndex - ySourceIndex) ?? 0);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
@@ -635,33 +635,24 @@ namespace SabreTools.DatItems
|
||||
int? ySourceIndex = y.GetFieldValue<Source?>(DatItem.SourceKey)?.Index;
|
||||
string? yType = y.GetStringFieldValue(Models.Metadata.DatItem.TypeKey);
|
||||
|
||||
// If machine names match, more refinement is needed
|
||||
if (xMachineName == yMachineName)
|
||||
{
|
||||
// If item types match, more refinement is needed
|
||||
if (xType == yType)
|
||||
{
|
||||
// If item directory names match, more refinement is needed
|
||||
if (xDirectoryName == yDirectoryName)
|
||||
{
|
||||
// If item names match, then compare on machine or source, depending on the flag
|
||||
if (xName == yName)
|
||||
return (norename ? nc.Compare(xMachineName, yMachineName) : (xSourceIndex - ySourceIndex) ?? 0);
|
||||
|
||||
// Otherwise, just sort based on item names
|
||||
return nc.Compare(xName, yName);
|
||||
}
|
||||
|
||||
// Otherwise, just sort based on directory name
|
||||
return nc.Compare(xDirectoryName, yDirectoryName);
|
||||
}
|
||||
|
||||
// Otherwise, just sort based on item type
|
||||
return xType.AsEnumValue<ItemType>() - yType.AsEnumValue<ItemType>();
|
||||
}
|
||||
|
||||
// Otherwise, just sort based on machine name
|
||||
// If machine names don't match
|
||||
if (xMachineName != yMachineName)
|
||||
return nc.Compare(xMachineName, yMachineName);
|
||||
|
||||
// If types don't match
|
||||
if (xType != yType)
|
||||
return xType.AsEnumValue<ItemType>() - yType.AsEnumValue<ItemType>();
|
||||
|
||||
// If directory names don't match
|
||||
if (xDirectoryName != yDirectoryName)
|
||||
return nc.Compare(xDirectoryName, yDirectoryName);
|
||||
|
||||
// If item names don't match
|
||||
if (xName != yName)
|
||||
return nc.Compare(xName, yName);
|
||||
|
||||
// Otherwise, compare on machine or source, depending on the flag
|
||||
return (norename ? nc.Compare(xMachineName, yMachineName) : (xSourceIndex - ySourceIndex) ?? 0);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user