Perform mass cleanup

This is cleanup based on both new .NET functionality (in 6 and 7) as well as a ton of simplifications and things that were missed that were caught due to the cleanup.
This commit is contained in:
Matt Nadareski
2023-04-19 16:39:58 -04:00
parent fd5fd79b95
commit 728b5d6b27
95 changed files with 1353 additions and 1572 deletions

View File

@@ -92,7 +92,7 @@ namespace SabreTools.Core.Tools
/// </summary>
public void Terminate()
{
byte[] emptyBuffer = new byte[0];
byte[] emptyBuffer = Array.Empty<byte>();
switch (HashType)
{
case Hash.CRC:
@@ -118,23 +118,17 @@ namespace SabreTools.Core.Tools
/// </summary>
public byte[] GetHash()
{
switch (HashType)
return HashType switch
{
case Hash.CRC:
return BitConverter.GetBytes((_hasher as OptimizedCRC.OptimizedCRC).Value).Reverse().ToArray();
case Hash.MD5:
case Hash.SHA1:
case Hash.SHA256:
case Hash.SHA384:
case Hash.SHA512:
return (_hasher as HashAlgorithm).Hash;
case Hash.SpamSum:
return (_hasher as SpamSumContext).Final();
}
return null;
Hash.CRC => BitConverter.GetBytes((_hasher as OptimizedCRC.OptimizedCRC).Value).Reverse().ToArray(),
Hash.MD5 => (_hasher as HashAlgorithm).Hash,
Hash.SHA1 => (_hasher as HashAlgorithm).Hash,
Hash.SHA256 => (_hasher as HashAlgorithm).Hash,
Hash.SHA384 => (_hasher as HashAlgorithm).Hash,
Hash.SHA512 => (_hasher as HashAlgorithm).Hash,
Hash.SpamSum => (_hasher as SpamSumContext).Final(),
_ => null,
};
}
}
}