Просмотр исходного кода

misc: chore: Use collection expressions in Common project

Evan Husted 1 год назад
Родитель
Сommit
0f857400b6

+ 1 - 1
src/Ryujinx.Common/Collections/IntervalTree.cs

@@ -106,7 +106,7 @@ namespace Ryujinx.Common.Collections
         /// <returns>A list of all RangeNodes sorted by Key Order</returns>
         public List<RangeNode<TKey, TValue>> AsList()
         {
-            List<RangeNode<TKey, TValue>> list = new();
+            List<RangeNode<TKey, TValue>> list = [];
 
             AddToList(Root, list);
 

+ 2 - 2
src/Ryujinx.Common/Collections/TreeDictionary.cs

@@ -139,7 +139,7 @@ namespace Ryujinx.Common.Collections
         /// <param name="list">List to add the tree pairs into</param>
         public List<KeyValuePair<TKey, TValue>> AsLevelOrderList()
         {
-            List<KeyValuePair<TKey, TValue>> list = new();
+            List<KeyValuePair<TKey, TValue>> list = [];
 
             Queue<Node<TKey, TValue>> nodes = new();
 
@@ -168,7 +168,7 @@ namespace Ryujinx.Common.Collections
         /// <returns>A list of all KeyValuePairs sorted by Key Order</returns>
         public List<KeyValuePair<TKey, TValue>> AsList()
         {
-            List<KeyValuePair<TKey, TValue>> list = new();
+            List<KeyValuePair<TKey, TValue>> list = [];
 
             AddToList(Root, list);
 

+ 1 - 1
src/Ryujinx.Common/Configuration/ModMetadata.cs

@@ -8,7 +8,7 @@ namespace Ryujinx.Common.Configuration
 
         public ModMetadata()
         {
-            Mods = new List<Mod>();
+            Mods = [];
         }
     }
 }

+ 2 - 2
src/Ryujinx.Common/Logging/Logger.cs

@@ -132,7 +132,7 @@ namespace Ryujinx.Common.Logging
                 _enabledClasses[index] = true;
             }
 
-            _logTargets = new List<ILogTarget>();
+            _logTargets = [];
 
             _time = Stopwatch.StartNew();
 
@@ -203,7 +203,7 @@ namespace Ryujinx.Common.Logging
 
         public static IReadOnlyCollection<LogLevel> GetEnabledLevels()
         {
-            Log?[] logs = new[] { Debug, Info, Warning, Error, Guest, AccessLog, Stub, Trace };
+            Log?[] logs = [Debug, Info, Warning, Error, Guest, AccessLog, Stub, Trace];
             List<LogLevel> levels = new(logs.Length);
             foreach (Log? log in logs)
             {

+ 2 - 2
src/Ryujinx.Common/PreciseSleep/NanosleepPool.cs

@@ -125,8 +125,8 @@ namespace Ryujinx.Common.PreciseSleep
         }
 
         private readonly Lock _lock = new();
-        private readonly List<NanosleepThread> _threads = new();
-        private readonly List<NanosleepThread> _active = new();
+        private readonly List<NanosleepThread> _threads = [];
+        private readonly List<NanosleepThread> _active = [];
         private readonly Stack<NanosleepThread> _free = new();
         private readonly AutoResetEvent _signalTarget;
 

+ 1 - 1
src/Ryujinx.Common/PreciseSleep/WindowsGranularTimer.cs

@@ -51,7 +51,7 @@ namespace Ryujinx.Common.SystemInterop
         private long _lastId;
 
         private readonly Lock _lock = new();
-        private readonly List<WaitingObject> _waitingObjects = new();
+        private readonly List<WaitingObject> _waitingObjects = [];
 
         private WindowsGranularTimer()
         {