misc: chore: Use collection expressions (part 2)

This commit is contained in:
KeatonTheBot
2025-03-10 21:32:01 -05:00
parent c923c0043a
commit 340ec79e9f
176 changed files with 308 additions and 308 deletions
@@ -64,7 +64,7 @@ namespace Ryujinx.HLE.HOS.Applets.Browser
public static (ShimKind, List<BrowserArgument>) ParseArguments(ReadOnlySpan<byte> data)
{
List<BrowserArgument> browserArguments = new();
List<BrowserArgument> browserArguments = [];
WebArgHeader header = IApplet.ReadStruct<WebArgHeader>(data[..8]);
@@ -9,10 +9,10 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler
class Demangler
{
private const string Base36 = "0123456789abcdefghijklmnopqrstuvwxyz";
private readonly List<BaseNode> _substitutionList = new();
private List<BaseNode> _templateParamList = new();
private readonly List<BaseNode> _substitutionList = [];
private List<BaseNode> _templateParamList = [];
private readonly List<ForwardTemplateReference> _forwardTemplateReferenceList = new();
private readonly List<ForwardTemplateReference> _forwardTemplateReferenceList = [];
public string Mangled { get; private set; }
@@ -274,7 +274,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler
}
else if (ConsumeIf("Dw"))
{
List<BaseNode> types = new();
List<BaseNode> types = [];
while (!ConsumeIf("E"))
{
@@ -308,7 +308,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler
}
Reference referenceQualifier = Reference.None;
List<BaseNode> paramsList = new();
List<BaseNode> paramsList = [];
while (true)
{
@@ -1588,7 +1588,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler
return null;
}
List<BaseNode> expressions = new();
List<BaseNode> expressions = [];
if (ConsumeIf("_"))
{
while (!ConsumeIf("E"))
@@ -1730,8 +1730,8 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler
return null;
}
List<BaseNode> expressions = new();
List<BaseNode> initializers = new();
List<BaseNode> expressions = [];
List<BaseNode> initializers = [];
while (!ConsumeIf("_"))
{
@@ -1899,7 +1899,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler
return null;
}
List<BaseNode> names = new();
List<BaseNode> names = [];
while (!ConsumeIf("E"))
{
expression = ParseExpression();
@@ -2048,7 +2048,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler
case 'l':
_position += 2;
List<BaseNode> bracedExpressions = new();
List<BaseNode> bracedExpressions = [];
while (!ConsumeIf("E"))
{
expression = ParseBracedExpression();
@@ -2327,7 +2327,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler
return null;
case 'P':
_position += 2;
List<BaseNode> arguments = new();
List<BaseNode> arguments = [];
while (!ConsumeIf("E"))
{
BaseNode argument = ParseTemplateArgument();
@@ -2368,7 +2368,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler
return null;
}
List<BaseNode> bracedExpressions = new();
List<BaseNode> bracedExpressions = [];
while (!ConsumeIf("E"))
{
expression = ParseBracedExpression();
@@ -2600,7 +2600,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler
_templateParamList.Clear();
}
List<BaseNode> args = new();
List<BaseNode> args = [];
while (!ConsumeIf("E"))
{
if (hasContext)
@@ -2659,7 +2659,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler
// J <template-arg>* E
case 'J':
_position++;
List<BaseNode> templateArguments = new();
List<BaseNode> templateArguments = [];
while (!ConsumeIf("E"))
{
BaseNode templateArgument = ParseTemplateArgument();
@@ -3298,7 +3298,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler
return new EncodedFunction(name, null, context.Cv, context.Ref, null, returnType);
}
List<BaseNode> paramsList = new();
List<BaseNode> paramsList = [];
// backup because that can be destroyed by parseType
CvType cv = context.Cv;
+7 -7
View File
@@ -26,13 +26,13 @@ namespace Ryujinx.HLE.HOS.Ipc
public IpcMessage()
{
PtrBuff = new List<IpcPtrBuffDesc>(0);
SendBuff = new List<IpcBuffDesc>(0);
ReceiveBuff = new List<IpcBuffDesc>(0);
ExchangeBuff = new List<IpcBuffDesc>(0);
RecvListBuff = new List<IpcRecvListBuffDesc>(0);
PtrBuff = [];
SendBuff = [];
ReceiveBuff = [];
ExchangeBuff = [];
RecvListBuff = [];
ObjectIds = new List<int>(0);
ObjectIds = [];
}
public IpcMessage(ReadOnlySpan<byte> data, long cmdPtr)
@@ -122,7 +122,7 @@ namespace Ryujinx.HLE.HOS.Ipc
RecvListBuff.Add(new IpcRecvListBuffDesc(reader.ReadUInt64()));
}
ObjectIds = new List<int>(0);
ObjectIds = [];
}
public RecyclableMemoryStream GetStream(long cmdPtr, ulong recvListAddr)
@@ -27,7 +27,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Common
_current2 = new long[(int)LimitableResource.Count];
_peak = new long[(int)LimitableResource.Count];
_waitingThreads = new LinkedList<KThread>();
_waitingThreads = [];
}
public bool Reserve(LimitableResource resource, ulong amount)
@@ -9,7 +9,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Common
public KSynchronizationObject(KernelContext context) : base(context)
{
WaitingThreads = new LinkedList<KThread>();
WaitingThreads = [];
}
public LinkedListNode<KThread> AddWaitingThread(KThread thread)
@@ -34,7 +34,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Common
public KTimeManager(KernelContext context)
{
_context = context;
_waitingObjects = new List<WaitingObject>();
_waitingObjects = [];
_keepRunning = true;
Thread work = new(WaitAndCheckScheduledObjects)
@@ -16,8 +16,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc
{
_parent = parent;
_incomingConnections = new LinkedList<KServerSession>();
_lightIncomingConnections = new LinkedList<KLightServerSession>();
_incomingConnections = [];
_lightIncomingConnections = [];
}
public void EnqueueIncomingSession(KServerSession session)
@@ -10,7 +10,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
public KPageList()
{
Nodes = new LinkedList<KPageNode>();
Nodes = [];
}
public Result AddRange(ulong address, ulong pagesCount)
@@ -8,7 +8,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
public KSlabHeap(ulong pa, ulong itemSize, ulong size)
{
_items = new LinkedList<ulong>();
_items = [];
int itemsCount = (int)(size / itemSize);
@@ -40,7 +40,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
{
_owner = owner;
_images = new List<Image>();
_images = [];
}
public string GetGuestStackTrace(KThread thread)
@@ -107,7 +107,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
// TODO: Remove once we no longer need to initialize it externally.
HandleTable = new KHandleTable();
_threads = new LinkedList<KThread>();
_threads = [];
Debugger = new HleProcessDebugger(this);
}
@@ -21,8 +21,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
{
_context = context;
_condVarThreads = new List<KThread>();
_arbiterThreads = new List<KThread>();
_condVarThreads = [];
_arbiterThreads = [];
}
public Result ArbitrateLock(int ownerHandle, ulong mutexAddress, int requesterHandle)
@@ -23,8 +23,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
for (int core = 0; core < KScheduler.CpuCoresCount; core++)
{
_suggestedThreadsPerPrioPerCore[prio][core] = new LinkedList<KThread>();
_scheduledThreadsPerPrioPerCore[prio][core] = new LinkedList<KThread>();
_suggestedThreadsPerPrioPerCore[prio][core] = [];
_scheduledThreadsPerPrioPerCore[prio][core] = [];
}
}
@@ -121,8 +121,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
SiblingsPerCore = new LinkedListNode<KThread>[KScheduler.CpuCoresCount];
_mutexWaiters = new LinkedList<KThread>();
_pinnedWaiters = new LinkedList<KThread>();
_mutexWaiters = [];
_pinnedWaiters = [];
}
public Result Initialize(
@@ -53,7 +53,7 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc
{
ProfilesJson profilesJson = new()
{
Profiles = new List<UserProfileJson>(),
Profiles = [],
LastOpened = LastOpened.ToString(),
};
@@ -852,8 +852,8 @@ namespace Ryujinx.HLE.HOS.Services.Hid
// Initialize entries to avoid issues with some games.
List<GamepadInput> emptyGamepadInputs = new();
List<SixAxisInput> emptySixAxisInputs = new();
List<GamepadInput> emptyGamepadInputs = [];
List<SixAxisInput> emptySixAxisInputs = [];
for (int player = 0; player < NpadDevices.MaxControllers; player++)
{
@@ -7,7 +7,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy
{
private const ushort EphemeralBase = 49152;
private readonly List<ushort> _ephemeralPorts = new List<ushort>();
private readonly List<ushort> _ephemeralPorts = [];
private readonly Lock _lock = new();
@@ -13,7 +13,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy
public EndPoint LocalEndpoint { get; }
public IPAddress LocalAddress { get; }
private readonly List<LdnProxySocket> _sockets = new List<LdnProxySocket>();
private readonly List<LdnProxySocket> _sockets = [];
private readonly Dictionary<ProtocolType, EphemeralPortPool> _ephemeralPorts = new Dictionary<ProtocolType, EphemeralPortPool>();
private readonly IProxyClient _parent;
@@ -18,7 +18,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy
private readonly LdnProxy _proxy;
private bool _isListening;
private readonly List<LdnProxySocket> _listenSockets = new List<LdnProxySocket>();
private readonly List<LdnProxySocket> _listenSockets = [];
private readonly Queue<ProxyConnectRequest> _connectRequests = new Queue<ProxyConnectRequest>();
@@ -39,9 +39,9 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy
private NatDevice _natDevice;
private Mapping _portMapping;
private readonly List<P2pProxySession> _players = new List<P2pProxySession>();
private readonly List<P2pProxySession> _players = [];
private readonly List<ExternalProxyToken> _waitingTokens = new List<ExternalProxyToken>();
private readonly List<ExternalProxyToken> _waitingTokens = [];
private readonly AutoResetEvent _tokenEvent = new AutoResetEvent(false);
private uint _broadcastAddress;
@@ -36,7 +36,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption
private byte[] DeriveKey(AmiiboMasterKey key, bool deriveAes, out byte[] derivedAesKey, out byte[] derivedAesIv)
{
List<byte> seed = new List<byte>();
List<byte> seed = [];
// Start with the type string (14 bytes)
seed.AddRange(key.TypeString);
@@ -5,7 +5,7 @@ namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService.GeneralService
{
static class GeneralServiceManager
{
private static readonly List<GeneralServiceDetail> _generalServices = new();
private static readonly List<GeneralServiceDetail> _generalServices = [];
public static int Count
{
@@ -15,7 +15,7 @@ namespace Ryujinx.HLE.HOS.Services.Ns.Aoc
private ulong _addOnContentBaseId;
private readonly List<ulong> _mountedAocTitleIds = new();
private readonly List<ulong> _mountedAocTitleIds = [];
public IAddOnContentManager(ServiceCtx context)
{
@@ -23,7 +23,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv
private readonly TreeDictionary<ulong, ulong> _tree = new();
private readonly Dictionary<ulong, LinkedListNode<ulong>> _dictionary = new();
private readonly LinkedList<ulong> _list = new();
private readonly LinkedList<ulong> _list = [];
public NvMemoryAllocator()
{
@@ -64,7 +64,7 @@ namespace Ryujinx.HLE.HOS.Services.Ro
return ResultCode.InvalidSize;
}
List<byte[]> hashes = new();
List<byte[]> hashes = [];
for (int i = 0; i < header.HashesCount; i++)
{
@@ -33,7 +33,7 @@ namespace Ryujinx.HLE.HOS.Services.Sdb.Pdm.QueryService
PlayLogQueryCapability queryCapability = (PlayLogQueryCapability)context.Device.Processes.ActiveApplication.ApplicationControlProperties.PlayLogQueryCapability;
List<ulong> titleIds = new();
List<ulong> titleIds = [];
for (ulong i = 0; i < inputSize / sizeof(ulong); i++)
{
@@ -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++)
{
@@ -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++)
{
@@ -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;
@@ -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);
@@ -66,7 +66,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
ConsumerListener = null;
ConsumerUsageBits = 0;
Queue = new List<BufferItem>();
Queue = [];
// TODO: CreateGraphicBufferAlloc?
@@ -12,7 +12,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.Clock
public SystemClockContextUpdateCallback()
{
_operationEventList = new List<KWritableEvent>();
_operationEventList = [];
Context = new SystemClockContext();
_hasContext = false;
}
@@ -34,7 +34,7 @@ namespace Ryujinx.HLE.HOS.Services.Vi.RootService
public IApplicationDisplayService(ViServiceType serviceType)
{
_serviceType = serviceType;
_displayInfo = new List<DisplayInfo>();
_displayInfo = [];
_openDisplays = new Dictionary<ulong, DisplayState>();
void AddDisplayInfo(string name, bool layerLimitEnabled, ulong layerLimitMax, ulong width, ulong height)
+1 -1
View File
@@ -11,7 +11,7 @@ namespace Ryujinx.HLE.HOS.Tamper
public OperationBlock(byte[] baseInstruction)
{
BaseInstruction = baseInstruction;
Operations = new List<IOperation>();
Operations = [];
}
}
}