misc: chore: Use collection expressions

This commit is contained in:
KeatonTheBot
2025-03-06 20:46:29 -06:00
parent 4d5757417e
commit e2973a875a
236 changed files with 9843 additions and 7561 deletions
@@ -32,11 +32,12 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
private const long AverageSecondsPerYear = 31556952;
private const long SecondsPerRepeat = YearsPerRepeat * AverageSecondsPerYear;
private static readonly int[] _yearLengths = { DaysPerNYear, DaysPerLYear };
private static readonly int[][] _monthsLengths = {
new[] { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },
new[] { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },
};
private static readonly int[] _yearLengths = [DaysPerNYear, DaysPerLYear];
private static readonly int[][] _monthsLengths =
[
[31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],
[31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
];
private static ReadOnlySpan<byte> TimeZoneDefaultRule => ",M4.1.0,M10.5.0"u8;
@@ -100,7 +100,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
StreamReader reader = new(binaryListFile.Get.AsStream());
List<string> locationNameList = new();
List<string> locationNameList = [];
string locationName;
while ((locationName = reader.ReadLine()) != null)
@@ -112,7 +112,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
}
else
{
LocationNameCache = new[] { "UTC" };
LocationNameCache = ["UTC"];
Logger.Error?.Print(LogClass.ServiceTime, TimeZoneSystemTitleMissingErrorMessage);
}
@@ -124,10 +124,10 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
if (string.IsNullOrEmpty(tzBinaryContentPath))
{
return new[] { (0, "UTC", "UTC") };
return [(0, "UTC", "UTC")];
}
List<(int Offset, string Location, string Abbr)> outList = new();
List<(int Offset, string Location, string Abbr)> outList = [];
var now = DateTimeOffset.Now.ToUnixTimeSeconds();
using (IStorage ncaStorage = new LocalStorage(VirtualFileSystem.SwitchPathToSystemPath(tzBinaryContentPath), FileAccess.Read, FileMode.Open))
using (IFileSystem romfs = new Nca(_virtualFileSystem.KeySet, ncaStorage).OpenFileSystem(NcaSectionType.Data, _fsIntegrityCheckLevel))
@@ -217,7 +217,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
public ResultCode LoadLocationNameList(uint index, out string[] outLocationNameArray, uint maxLength)
{
List<string> locationNameList = new();
List<string> locationNameList = [];
for (int i = 0; i < LocationNameCache.Length && i < maxLength; i++)
{
@@ -231,7 +231,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
// If the location name is too long, error out.
if (locationName.Length > 0x24)
{
outLocationNameArray = Array.Empty<string>();
outLocationNameArray = [];
return ResultCode.LocationNameTooLong;
}