1616using System . Collections . Generic ;
1717using System . Collections . Immutable ;
1818using System . Linq ;
19+ using System . Runtime . CompilerServices ;
1920
2021namespace OnixLabs . Core . Collections ;
2122
@@ -29,6 +30,7 @@ public static partial class Collection
2930 /// </summary>
3031 /// <typeparam name="T">The underlying type of the enumerable.</typeparam>
3132 /// <returns>Returns an empty enumerable.</returns>
33+ [ MethodImpl ( MethodImplOptions . AggressiveInlining | MethodImplOptions . AggressiveOptimization ) ]
3234 public static IEnumerable < T > EmptyEnumerable < T > ( )
3335 {
3436 return Enumerable . Empty < T > ( ) ;
@@ -39,6 +41,7 @@ public static IEnumerable<T> EmptyEnumerable<T>()
3941 /// </summary>
4042 /// <typeparam name="T">The underlying type of the array.</typeparam>
4143 /// <returns>Returns an empty array.</returns>
44+ [ MethodImpl ( MethodImplOptions . AggressiveInlining | MethodImplOptions . AggressiveOptimization ) ]
4245 public static T [ ] EmptyArray < T > ( )
4346 {
4447 return Array . Empty < T > ( ) ;
@@ -49,6 +52,7 @@ public static T[] EmptyArray<T>()
4952 /// </summary>
5053 /// <typeparam name="T">The underlying type of the immutable array.</typeparam>
5154 /// <returns>Returns an empty immutable array.</returns>
55+ [ MethodImpl ( MethodImplOptions . AggressiveInlining | MethodImplOptions . AggressiveOptimization ) ]
5256 public static ImmutableArray < T > EmptyImmutableArray < T > ( )
5357 {
5458 return ImmutableArray < T > . Empty ;
@@ -59,16 +63,18 @@ public static ImmutableArray<T> EmptyImmutableArray<T>()
5963 /// </summary>
6064 /// <typeparam name="T">The underlying type of the list.</typeparam>
6165 /// <returns>Returns an empty list.</returns>
66+ [ MethodImpl ( MethodImplOptions . AggressiveInlining | MethodImplOptions . AggressiveOptimization ) ]
6267 public static List < T > EmptyList < T > ( )
6368 {
64- return new List < T > ( ) ;
69+ return [ ] ;
6570 }
6671
6772 /// <summary>
6873 /// Creates an empty immutable list.
6974 /// </summary>
7075 /// <typeparam name="T">The underlying type of the immutable list.</typeparam>
7176 /// <returns>Returns an empty immutable list.</returns>
77+ [ MethodImpl ( MethodImplOptions . AggressiveInlining | MethodImplOptions . AggressiveOptimization ) ]
7278 public static ImmutableList < T > EmptyImmutableList < T > ( )
7379 {
7480 return ImmutableList < T > . Empty ;
@@ -80,9 +86,10 @@ public static ImmutableList<T> EmptyImmutableList<T>()
8086 /// <typeparam name="TKey">The underlying type of the dictionary key.</typeparam>
8187 /// <typeparam name="TValue">The underlying type of the dictionary value.</typeparam>
8288 /// <returns>Returns an empty dictionary.</returns>
89+ [ MethodImpl ( MethodImplOptions . AggressiveInlining | MethodImplOptions . AggressiveOptimization ) ]
8390 public static Dictionary < TKey , TValue > EmptyDictionary < TKey , TValue > ( ) where TKey : notnull
8491 {
85- return new Dictionary < TKey , TValue > ( ) ;
92+ return [ ] ;
8693 }
8794
8895 /// <summary>
@@ -91,6 +98,7 @@ public static Dictionary<TKey, TValue> EmptyDictionary<TKey, TValue>() where TKe
9198 /// <typeparam name="TKey">The underlying type of the immutable dictionary key.</typeparam>
9299 /// <typeparam name="TValue">The underlying type of the immutable dictionary value.</typeparam>
93100 /// <returns>Returns an empty immutable dictionary.</returns>
101+ [ MethodImpl ( MethodImplOptions . AggressiveInlining | MethodImplOptions . AggressiveOptimization ) ]
94102 public static ImmutableDictionary < TKey , TValue > EmptyImmutableDictionary < TKey , TValue > ( ) where TKey : notnull
95103 {
96104 return ImmutableDictionary < TKey , TValue > . Empty ;
@@ -102,9 +110,10 @@ public static ImmutableDictionary<TKey, TValue> EmptyImmutableDictionary<TKey, T
102110 /// <typeparam name="TKey">The underlying type of the sorted dictionary key.</typeparam>
103111 /// <typeparam name="TValue">The underlying type of the sorted dictionary value.</typeparam>
104112 /// <returns>Returns an empty sorted dictionary.</returns>
113+ [ MethodImpl ( MethodImplOptions . AggressiveInlining | MethodImplOptions . AggressiveOptimization ) ]
105114 public static SortedDictionary < TKey , TValue > EmptySortedDictionary < TKey , TValue > ( ) where TKey : notnull
106115 {
107- return new SortedDictionary < TKey , TValue > ( ) ;
116+ return [ ] ;
108117 }
109118
110119 /// <summary>
@@ -113,6 +122,7 @@ public static SortedDictionary<TKey, TValue> EmptySortedDictionary<TKey, TValue>
113122 /// <typeparam name="TKey">The underlying type of the immutable sorted dictionary key.</typeparam>
114123 /// <typeparam name="TValue">The underlying type of the immutable sorted dictionary value.</typeparam>
115124 /// <returns>Returns an empty immutable sorted dictionary.</returns>
125+ [ MethodImpl ( MethodImplOptions . AggressiveInlining | MethodImplOptions . AggressiveOptimization ) ]
116126 public static ImmutableSortedDictionary < TKey , TValue > EmptyImmutableSortedDictionary < TKey , TValue > ( ) where TKey : notnull
117127 {
118128 return ImmutableSortedDictionary < TKey , TValue > . Empty ;
@@ -123,16 +133,18 @@ public static ImmutableSortedDictionary<TKey, TValue> EmptyImmutableSortedDictio
123133 /// </summary>
124134 /// <typeparam name="T">The underlying type of the hash set.</typeparam>
125135 /// <returns>Returns an empty hash set.</returns>
136+ [ MethodImpl ( MethodImplOptions . AggressiveInlining | MethodImplOptions . AggressiveOptimization ) ]
126137 public static HashSet < T > EmptyHashSet < T > ( )
127138 {
128- return new HashSet < T > ( ) ;
139+ return [ ] ;
129140 }
130141
131142 /// <summary>
132143 /// Creates an empty immutable hash set.
133144 /// </summary>
134145 /// <typeparam name="T">The underlying type of the immutable hash set.</typeparam>
135146 /// <returns>Returns an empty immutable hash set.</returns>
147+ [ MethodImpl ( MethodImplOptions . AggressiveInlining | MethodImplOptions . AggressiveOptimization ) ]
136148 public static ImmutableHashSet < T > EmptyImmutableHashSet < T > ( )
137149 {
138150 return ImmutableHashSet < T > . Empty ;
@@ -143,16 +155,18 @@ public static ImmutableHashSet<T> EmptyImmutableHashSet<T>()
143155 /// </summary>
144156 /// <typeparam name="T">The underlying type of the sorted set.</typeparam>
145157 /// <returns>Returns an empty sorted set.</returns>
158+ [ MethodImpl ( MethodImplOptions . AggressiveInlining | MethodImplOptions . AggressiveOptimization ) ]
146159 public static SortedSet < T > EmptySortedSet < T > ( )
147160 {
148- return new SortedSet < T > ( ) ;
161+ return [ ] ;
149162 }
150163
151164 /// <summary>
152165 /// Creates an empty immutable sorted set.
153166 /// </summary>
154167 /// <typeparam name="T">The underlying type of the immutable sorted set.</typeparam>
155168 /// <returns>Returns an empty immutable sorted set.</returns>
169+ [ MethodImpl ( MethodImplOptions . AggressiveInlining | MethodImplOptions . AggressiveOptimization ) ]
156170 public static ImmutableSortedSet < T > EmptyImmutableSortedSet < T > ( )
157171 {
158172 return ImmutableSortedSet < T > . Empty ;
@@ -163,16 +177,18 @@ public static ImmutableSortedSet<T> EmptyImmutableSortedSet<T>()
163177 /// </summary>
164178 /// <typeparam name="T">The underlying type of the stack.</typeparam>
165179 /// <returns>Returns an empty stack.</returns>
180+ [ MethodImpl ( MethodImplOptions . AggressiveInlining | MethodImplOptions . AggressiveOptimization ) ]
166181 public static Stack < T > EmptyStack < T > ( )
167182 {
168- return new Stack < T > ( ) ;
183+ return [ ] ;
169184 }
170185
171186 /// <summary>
172187 /// Creates an empty immutable stack.
173188 /// </summary>
174189 /// <typeparam name="T">The underlying type of the immutable stack.</typeparam>
175190 /// <returns>Returns an empty immutable stack.</returns>
191+ [ MethodImpl ( MethodImplOptions . AggressiveInlining | MethodImplOptions . AggressiveOptimization ) ]
176192 public static ImmutableStack < T > EmptyImmutableStack < T > ( )
177193 {
178194 return ImmutableStack < T > . Empty ;
@@ -183,16 +199,18 @@ public static ImmutableStack<T> EmptyImmutableStack<T>()
183199 /// </summary>
184200 /// <typeparam name="T">The underlying type of the queue.</typeparam>
185201 /// <returns>Returns an empty queue.</returns>
202+ [ MethodImpl ( MethodImplOptions . AggressiveInlining | MethodImplOptions . AggressiveOptimization ) ]
186203 public static Queue < T > EmptyQueue < T > ( )
187204 {
188- return new Queue < T > ( ) ;
205+ return [ ] ;
189206 }
190207
191208 /// <summary>
192209 /// Creates an empty immutable queue.
193210 /// </summary>
194211 /// <typeparam name="T">The underlying type of the immutable queue.</typeparam>
195212 /// <returns>Returns an empty immutable queue.</returns>
213+ [ MethodImpl ( MethodImplOptions . AggressiveInlining | MethodImplOptions . AggressiveOptimization ) ]
196214 public static ImmutableQueue < T > EmptyImmutableQueue < T > ( )
197215 {
198216 return ImmutableQueue < T > . Empty ;
0 commit comments