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

@@ -17,7 +17,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
private BsdContext()
{
_fds = new List<IFileDescriptor>();
_fds = [];
}
public ISocket RetrieveSocket(int socketFd)
@@ -47,7 +47,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
public List<IFileDescriptor> RetrieveFileDescriptorsFromMask(ReadOnlySpan<byte> mask)
{
List<IFileDescriptor> fds = new();
List<IFileDescriptor> fds = [];
for (int i = 0; i < mask.Length; i++)
{

View File

@@ -16,11 +16,11 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
[Service("bsd:u", false)]
class IClient : IpcService
{
private static readonly List<IPollManager> _pollManagers = new()
{
private static readonly List<IPollManager> _pollManagers =
[
EventFileDescriptorPollManager.Instance,
ManagedSocketPollManager.Instance,
};
ManagedSocketPollManager.Instance
];
private BsdContext _context;
private readonly bool _isPrivileged;
@@ -265,7 +265,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
for (int i = 0; i < eventsByPollManager.Length; i++)
{
eventsByPollManager[i] = new List<PollEvent>();
eventsByPollManager[i] = [];
foreach (PollEvent evnt in events)
{
@@ -361,12 +361,12 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
events[i] = new PollEvent(pollEventData, fileDescriptor);
}
List<PollEvent> discoveredEvents = new();
List<PollEvent> discoveredEvents = [];
List<PollEvent>[] eventsByPollManager = new List<PollEvent>[_pollManagers.Count];
for (int i = 0; i < eventsByPollManager.Length; i++)
{
eventsByPollManager[i] = new List<PollEvent>();
eventsByPollManager[i] = [];
foreach (PollEvent evnt in events)
{

View File

@@ -28,7 +28,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
{
updatedCount = 0;
List<ManualResetEvent> waiters = new();
List<ManualResetEvent> waiters = [];
for (int i = 0; i < events.Count; i++)
{

View File

@@ -27,9 +27,9 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
public LinuxError Poll(List<PollEvent> events, int timeoutMilliseconds, out int updatedCount)
{
List<ISocketImpl> readEvents = new();
List<ISocketImpl> writeEvents = new();
List<ISocketImpl> errorEvents = new();
List<ISocketImpl> readEvents = [];
List<ISocketImpl> writeEvents = [];
List<ISocketImpl> errorEvents = [];
updatedCount = 0;
@@ -123,9 +123,9 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
public LinuxError Select(List<PollEvent> events, int timeout, out int updatedCount)
{
List<ISocketImpl> readEvents = new();
List<ISocketImpl> writeEvents = new();
List<ISocketImpl> errorEvents = new();
List<ISocketImpl> readEvents = [];
List<ISocketImpl> writeEvents = [];
List<ISocketImpl> errorEvents = [];
updatedCount = 0;

View File

@@ -604,7 +604,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres
private static List<AddrInfoSerialized> DeserializeAddrInfos(IVirtualMemoryManager memory, ulong address, ulong size)
{
List<AddrInfoSerialized> result = new();
List<AddrInfoSerialized> result = [];
ReadOnlySpan<byte> data = memory.GetSpan(address, (int)size);

View File

@@ -19,14 +19,15 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres.Proxy
[GeneratedRegex(@"^accounts\.nintendo\.com$", RegexOpts)]
private static partial Regex BlockedHost6();
private static readonly Regex[] _blockedHosts = {
private static readonly Regex[] _blockedHosts =
[
BlockedHost1(),
BlockedHost2(),
BlockedHost3(),
BlockedHost4(),
BlockedHost5(),
BlockedHost6(),
};
BlockedHost6()
];
public static bool IsHostBlocked(string host)
{

View File

@@ -44,7 +44,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres.Proxy
continue;
}
string[] entry = line.Split(new[] { ' ', '\t' }, StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries);
string[] entry = line.Split([' ', '\t'], StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries);
// Hosts file example entry:
// 127.0.0.1 localhost loopback
@@ -92,9 +92,9 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres.Proxy
return new IPHostEntry
{
AddressList = new[] { hostEntry.Value },
AddressList = [hostEntry.Value],
HostName = hostEntry.Key,
Aliases = Array.Empty<string>(),
Aliases = [],
};
}
}