16
16
using System . Collections . Generic ;
17
17
using System . Collections . Immutable ;
18
18
using System . Linq ;
19
+ using System . Runtime . CompilerServices ;
19
20
20
21
namespace OnixLabs . Core . Collections ;
21
22
@@ -29,6 +30,7 @@ public static partial class Collection
29
30
/// </summary>
30
31
/// <typeparam name="T">The underlying type of the enumerable.</typeparam>
31
32
/// <returns>Returns an empty enumerable.</returns>
33
+ [ MethodImpl ( MethodImplOptions . AggressiveInlining | MethodImplOptions . AggressiveOptimization ) ]
32
34
public static IEnumerable < T > EmptyEnumerable < T > ( )
33
35
{
34
36
return Enumerable . Empty < T > ( ) ;
@@ -39,6 +41,7 @@ public static IEnumerable<T> EmptyEnumerable<T>()
39
41
/// </summary>
40
42
/// <typeparam name="T">The underlying type of the array.</typeparam>
41
43
/// <returns>Returns an empty array.</returns>
44
+ [ MethodImpl ( MethodImplOptions . AggressiveInlining | MethodImplOptions . AggressiveOptimization ) ]
42
45
public static T [ ] EmptyArray < T > ( )
43
46
{
44
47
return Array . Empty < T > ( ) ;
@@ -49,6 +52,7 @@ public static T[] EmptyArray<T>()
49
52
/// </summary>
50
53
/// <typeparam name="T">The underlying type of the immutable array.</typeparam>
51
54
/// <returns>Returns an empty immutable array.</returns>
55
+ [ MethodImpl ( MethodImplOptions . AggressiveInlining | MethodImplOptions . AggressiveOptimization ) ]
52
56
public static ImmutableArray < T > EmptyImmutableArray < T > ( )
53
57
{
54
58
return ImmutableArray < T > . Empty ;
@@ -59,16 +63,18 @@ public static ImmutableArray<T> EmptyImmutableArray<T>()
59
63
/// </summary>
60
64
/// <typeparam name="T">The underlying type of the list.</typeparam>
61
65
/// <returns>Returns an empty list.</returns>
66
+ [ MethodImpl ( MethodImplOptions . AggressiveInlining | MethodImplOptions . AggressiveOptimization ) ]
62
67
public static List < T > EmptyList < T > ( )
63
68
{
64
- return new List < T > ( ) ;
69
+ return [ ] ;
65
70
}
66
71
67
72
/// <summary>
68
73
/// Creates an empty immutable list.
69
74
/// </summary>
70
75
/// <typeparam name="T">The underlying type of the immutable list.</typeparam>
71
76
/// <returns>Returns an empty immutable list.</returns>
77
+ [ MethodImpl ( MethodImplOptions . AggressiveInlining | MethodImplOptions . AggressiveOptimization ) ]
72
78
public static ImmutableList < T > EmptyImmutableList < T > ( )
73
79
{
74
80
return ImmutableList < T > . Empty ;
@@ -80,9 +86,10 @@ public static ImmutableList<T> EmptyImmutableList<T>()
80
86
/// <typeparam name="TKey">The underlying type of the dictionary key.</typeparam>
81
87
/// <typeparam name="TValue">The underlying type of the dictionary value.</typeparam>
82
88
/// <returns>Returns an empty dictionary.</returns>
89
+ [ MethodImpl ( MethodImplOptions . AggressiveInlining | MethodImplOptions . AggressiveOptimization ) ]
83
90
public static Dictionary < TKey , TValue > EmptyDictionary < TKey , TValue > ( ) where TKey : notnull
84
91
{
85
- return new Dictionary < TKey , TValue > ( ) ;
92
+ return [ ] ;
86
93
}
87
94
88
95
/// <summary>
@@ -91,6 +98,7 @@ public static Dictionary<TKey, TValue> EmptyDictionary<TKey, TValue>() where TKe
91
98
/// <typeparam name="TKey">The underlying type of the immutable dictionary key.</typeparam>
92
99
/// <typeparam name="TValue">The underlying type of the immutable dictionary value.</typeparam>
93
100
/// <returns>Returns an empty immutable dictionary.</returns>
101
+ [ MethodImpl ( MethodImplOptions . AggressiveInlining | MethodImplOptions . AggressiveOptimization ) ]
94
102
public static ImmutableDictionary < TKey , TValue > EmptyImmutableDictionary < TKey , TValue > ( ) where TKey : notnull
95
103
{
96
104
return ImmutableDictionary < TKey , TValue > . Empty ;
@@ -102,9 +110,10 @@ public static ImmutableDictionary<TKey, TValue> EmptyImmutableDictionary<TKey, T
102
110
/// <typeparam name="TKey">The underlying type of the sorted dictionary key.</typeparam>
103
111
/// <typeparam name="TValue">The underlying type of the sorted dictionary value.</typeparam>
104
112
/// <returns>Returns an empty sorted dictionary.</returns>
113
+ [ MethodImpl ( MethodImplOptions . AggressiveInlining | MethodImplOptions . AggressiveOptimization ) ]
105
114
public static SortedDictionary < TKey , TValue > EmptySortedDictionary < TKey , TValue > ( ) where TKey : notnull
106
115
{
107
- return new SortedDictionary < TKey , TValue > ( ) ;
116
+ return [ ] ;
108
117
}
109
118
110
119
/// <summary>
@@ -113,6 +122,7 @@ public static SortedDictionary<TKey, TValue> EmptySortedDictionary<TKey, TValue>
113
122
/// <typeparam name="TKey">The underlying type of the immutable sorted dictionary key.</typeparam>
114
123
/// <typeparam name="TValue">The underlying type of the immutable sorted dictionary value.</typeparam>
115
124
/// <returns>Returns an empty immutable sorted dictionary.</returns>
125
+ [ MethodImpl ( MethodImplOptions . AggressiveInlining | MethodImplOptions . AggressiveOptimization ) ]
116
126
public static ImmutableSortedDictionary < TKey , TValue > EmptyImmutableSortedDictionary < TKey , TValue > ( ) where TKey : notnull
117
127
{
118
128
return ImmutableSortedDictionary < TKey , TValue > . Empty ;
@@ -123,16 +133,18 @@ public static ImmutableSortedDictionary<TKey, TValue> EmptyImmutableSortedDictio
123
133
/// </summary>
124
134
/// <typeparam name="T">The underlying type of the hash set.</typeparam>
125
135
/// <returns>Returns an empty hash set.</returns>
136
+ [ MethodImpl ( MethodImplOptions . AggressiveInlining | MethodImplOptions . AggressiveOptimization ) ]
126
137
public static HashSet < T > EmptyHashSet < T > ( )
127
138
{
128
- return new HashSet < T > ( ) ;
139
+ return [ ] ;
129
140
}
130
141
131
142
/// <summary>
132
143
/// Creates an empty immutable hash set.
133
144
/// </summary>
134
145
/// <typeparam name="T">The underlying type of the immutable hash set.</typeparam>
135
146
/// <returns>Returns an empty immutable hash set.</returns>
147
+ [ MethodImpl ( MethodImplOptions . AggressiveInlining | MethodImplOptions . AggressiveOptimization ) ]
136
148
public static ImmutableHashSet < T > EmptyImmutableHashSet < T > ( )
137
149
{
138
150
return ImmutableHashSet < T > . Empty ;
@@ -143,16 +155,18 @@ public static ImmutableHashSet<T> EmptyImmutableHashSet<T>()
143
155
/// </summary>
144
156
/// <typeparam name="T">The underlying type of the sorted set.</typeparam>
145
157
/// <returns>Returns an empty sorted set.</returns>
158
+ [ MethodImpl ( MethodImplOptions . AggressiveInlining | MethodImplOptions . AggressiveOptimization ) ]
146
159
public static SortedSet < T > EmptySortedSet < T > ( )
147
160
{
148
- return new SortedSet < T > ( ) ;
161
+ return [ ] ;
149
162
}
150
163
151
164
/// <summary>
152
165
/// Creates an empty immutable sorted set.
153
166
/// </summary>
154
167
/// <typeparam name="T">The underlying type of the immutable sorted set.</typeparam>
155
168
/// <returns>Returns an empty immutable sorted set.</returns>
169
+ [ MethodImpl ( MethodImplOptions . AggressiveInlining | MethodImplOptions . AggressiveOptimization ) ]
156
170
public static ImmutableSortedSet < T > EmptyImmutableSortedSet < T > ( )
157
171
{
158
172
return ImmutableSortedSet < T > . Empty ;
@@ -163,16 +177,18 @@ public static ImmutableSortedSet<T> EmptyImmutableSortedSet<T>()
163
177
/// </summary>
164
178
/// <typeparam name="T">The underlying type of the stack.</typeparam>
165
179
/// <returns>Returns an empty stack.</returns>
180
+ [ MethodImpl ( MethodImplOptions . AggressiveInlining | MethodImplOptions . AggressiveOptimization ) ]
166
181
public static Stack < T > EmptyStack < T > ( )
167
182
{
168
- return new Stack < T > ( ) ;
183
+ return [ ] ;
169
184
}
170
185
171
186
/// <summary>
172
187
/// Creates an empty immutable stack.
173
188
/// </summary>
174
189
/// <typeparam name="T">The underlying type of the immutable stack.</typeparam>
175
190
/// <returns>Returns an empty immutable stack.</returns>
191
+ [ MethodImpl ( MethodImplOptions . AggressiveInlining | MethodImplOptions . AggressiveOptimization ) ]
176
192
public static ImmutableStack < T > EmptyImmutableStack < T > ( )
177
193
{
178
194
return ImmutableStack < T > . Empty ;
@@ -183,16 +199,18 @@ public static ImmutableStack<T> EmptyImmutableStack<T>()
183
199
/// </summary>
184
200
/// <typeparam name="T">The underlying type of the queue.</typeparam>
185
201
/// <returns>Returns an empty queue.</returns>
202
+ [ MethodImpl ( MethodImplOptions . AggressiveInlining | MethodImplOptions . AggressiveOptimization ) ]
186
203
public static Queue < T > EmptyQueue < T > ( )
187
204
{
188
- return new Queue < T > ( ) ;
205
+ return [ ] ;
189
206
}
190
207
191
208
/// <summary>
192
209
/// Creates an empty immutable queue.
193
210
/// </summary>
194
211
/// <typeparam name="T">The underlying type of the immutable queue.</typeparam>
195
212
/// <returns>Returns an empty immutable queue.</returns>
213
+ [ MethodImpl ( MethodImplOptions . AggressiveInlining | MethodImplOptions . AggressiveOptimization ) ]
196
214
public static ImmutableQueue < T > EmptyImmutableQueue < T > ( )
197
215
{
198
216
return ImmutableQueue < T > . Empty ;
0 commit comments