misc: chore: Use collection expressions in HLE project

This commit is contained in:
Evan Husted
2025-01-26 15:43:02 -06:00
parent 3c2f283ec7
commit 70b767ef60
72 changed files with 312 additions and 299 deletions

View File

@@ -12,7 +12,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.Clock
public SystemClockContextUpdateCallback()
{
_operationEventList = new List<KWritableEvent>();
_operationEventList = [];
Context = new SystemClockContext();
_hasContext = false;
}

View File

@@ -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;

View File

@@ -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 = [];
long 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;
}