@@ -28,7 +28,7 @@ public static partial class Collection
2828 /// <returns>Returns an enumerable populated with the specified items.</returns>
2929 public static IEnumerable < T > EnumerableOf < T > ( params T [ ] items )
3030 {
31- return items . Copy ( ) ;
31+ return items ;
3232 }
3333
3434 /// <summary>
@@ -39,7 +39,7 @@ public static IEnumerable<T> EnumerableOf<T>(params T[] items)
3939 /// <returns>Returns an array populated with the specified items.</returns>
4040 public static T [ ] ArrayOf < T > ( params T [ ] items )
4141 {
42- return items . Copy ( ) ;
42+ return items ;
4343 }
4444
4545 /// <summary>
@@ -50,7 +50,7 @@ public static T[] ArrayOf<T>(params T[] items)
5050 /// <returns>Returns an immutable array populated with the specified items.</returns>
5151 public static ImmutableArray < T > ImmutableArrayOf < T > ( params T [ ] items )
5252 {
53- return ArrayOf ( items ) . ToImmutableArray ( ) ;
53+ return ImmutableArray . Create ( items ) ;
5454 }
5555
5656 /// <summary>
@@ -61,7 +61,7 @@ public static ImmutableArray<T> ImmutableArrayOf<T>(params T[] items)
6161 /// <returns>Returns a list populated with the specified items.</returns>
6262 public static List < T > ListOf < T > ( params T [ ] items )
6363 {
64- return new List < T > ( items . Copy ( ) ) ;
64+ return new List < T > ( items ) ;
6565 }
6666
6767 /// <summary>
@@ -72,7 +72,7 @@ public static List<T> ListOf<T>(params T[] items)
7272 /// <returns>Returns an immutable list populated with the specified items.</returns>
7373 public static ImmutableList < T > ImmutableListOf < T > ( params T [ ] items )
7474 {
75- return ListOf ( items ) . ToImmutableList ( ) ;
75+ return ImmutableList . Create ( items ) ;
7676 }
7777
7878 /// <summary>
@@ -84,7 +84,7 @@ public static ImmutableList<T> ImmutableListOf<T>(params T[] items)
8484 /// <returns>Returns a dictionary populated with the specified items.</returns>
8585 public static Dictionary < TKey , TValue > DictionaryOf < TKey , TValue > ( params KeyValuePair < TKey , TValue > [ ] items ) where TKey : notnull
8686 {
87- return new Dictionary < TKey , TValue > ( items . Copy ( ) ) ;
87+ return new Dictionary < TKey , TValue > ( items ) ;
8888 }
8989
9090 /// <summary>
@@ -109,7 +109,7 @@ public static Dictionary<TKey, TValue> DictionaryOf<TKey, TValue>(params (TKey k
109109 public static ImmutableDictionary < TKey , TValue > ImmutableDictionaryOf < TKey , TValue > (
110110 params KeyValuePair < TKey , TValue > [ ] items ) where TKey : notnull
111111 {
112- return DictionaryOf ( items ) . ToImmutableDictionary ( ) ;
112+ return ImmutableDictionary . CreateRange ( items ) ;
113113 }
114114
115115 /// <summary>
@@ -122,7 +122,7 @@ public static ImmutableDictionary<TKey, TValue> ImmutableDictionaryOf<TKey, TVal
122122 public static ImmutableDictionary < TKey , TValue > ImmutableDictionaryOf < TKey , TValue > (
123123 params ( TKey key , TValue value ) [ ] items ) where TKey : notnull
124124 {
125- return DictionaryOf ( items ) . ToImmutableDictionary ( ) ;
125+ return ImmutableDictionary . CreateRange ( items . Select ( item => new KeyValuePair < TKey , TValue > ( item . key , item . value ) ) ) ;
126126 }
127127
128128 /// <summary>
@@ -161,7 +161,7 @@ public static SortedDictionary<TKey, TValue> SortedDictionaryOf<TKey, TValue>(
161161 public static ImmutableSortedDictionary < TKey , TValue > ImmutableSortedDictionaryOf < TKey , TValue > (
162162 params KeyValuePair < TKey , TValue > [ ] items ) where TKey : notnull
163163 {
164- return SortedDictionaryOf ( items ) . ToImmutableSortedDictionary ( ) ;
164+ return ImmutableSortedDictionary . CreateRange ( items ) ;
165165 }
166166
167167 /// <summary>
@@ -174,7 +174,7 @@ public static ImmutableSortedDictionary<TKey, TValue> ImmutableSortedDictionaryO
174174 public static ImmutableSortedDictionary < TKey , TValue > ImmutableSortedDictionaryOf < TKey , TValue > (
175175 params ( TKey key , TValue value ) [ ] items ) where TKey : notnull
176176 {
177- return SortedDictionaryOf ( items ) . ToImmutableSortedDictionary ( ) ;
177+ return ImmutableSortedDictionary . CreateRange ( items . Select ( item => new KeyValuePair < TKey , TValue > ( item . key , item . value ) ) ) ;
178178 }
179179
180180 /// <summary>
@@ -185,7 +185,7 @@ public static ImmutableSortedDictionary<TKey, TValue> ImmutableSortedDictionaryO
185185 /// <returns>Returns a hash set populated with the specified items.</returns>
186186 public static HashSet < T > HashSetOf < T > ( params T [ ] items )
187187 {
188- return new HashSet < T > ( items . Copy ( ) ) ;
188+ return new HashSet < T > ( items ) ;
189189 }
190190
191191 /// <summary>
@@ -196,7 +196,7 @@ public static HashSet<T> HashSetOf<T>(params T[] items)
196196 /// <returns>Returns an immutable hash set populated with the specified items.</returns>
197197 public static ImmutableHashSet < T > ImmutableHashSetOf < T > ( params T [ ] items )
198198 {
199- return HashSetOf ( items ) . ToImmutableHashSet ( ) ;
199+ return ImmutableHashSet . Create ( items ) ;
200200 }
201201
202202 /// <summary>
@@ -207,7 +207,7 @@ public static ImmutableHashSet<T> ImmutableHashSetOf<T>(params T[] items)
207207 /// <returns>Returns a sorted set populated with the specified items.</returns>
208208 public static SortedSet < T > SortedSetOf < T > ( params T [ ] items )
209209 {
210- return new SortedSet < T > ( items . Copy ( ) ) ;
210+ return new SortedSet < T > ( items ) ;
211211 }
212212
213213 /// <summary>
@@ -218,7 +218,7 @@ public static SortedSet<T> SortedSetOf<T>(params T[] items)
218218 /// <returns>Returns an immutable sorted set populated with the specified items.</returns>
219219 public static ImmutableSortedSet < T > ImmutableSortedSetOf < T > ( params T [ ] items )
220220 {
221- return SortedSetOf ( items ) . ToImmutableSortedSet ( ) ;
221+ return ImmutableSortedSet . Create ( items ) ;
222222 }
223223
224224 /// <summary>
@@ -229,7 +229,7 @@ public static ImmutableSortedSet<T> ImmutableSortedSetOf<T>(params T[] items)
229229 /// <returns>Returns a stack populated with the specified items.</returns>
230230 public static Stack < T > StackOf < T > ( params T [ ] items )
231231 {
232- return new Stack < T > ( items . Copy ( ) ) ;
232+ return new Stack < T > ( items ) ;
233233 }
234234
235235 /// <summary>
@@ -240,7 +240,7 @@ public static Stack<T> StackOf<T>(params T[] items)
240240 /// <returns>Returns an immutable stack populated with the specified items.</returns>
241241 public static ImmutableStack < T > ImmutableStackOf < T > ( params T [ ] items )
242242 {
243- return ImmutableStack . Create ( items . Copy ( ) ) ;
243+ return ImmutableStack . Create ( items ) ;
244244 }
245245
246246 /// <summary>
@@ -251,7 +251,7 @@ public static ImmutableStack<T> ImmutableStackOf<T>(params T[] items)
251251 /// <returns>Returns a queue populated with the specified items.</returns>
252252 public static Queue < T > QueueOf < T > ( params T [ ] items )
253253 {
254- return new Queue < T > ( items . Copy ( ) ) ;
254+ return new Queue < T > ( items ) ;
255255 }
256256
257257 /// <summary>
@@ -262,6 +262,6 @@ public static Queue<T> QueueOf<T>(params T[] items)
262262 /// <returns>Returns an immutable queue populated with the specified items.</returns>
263263 public static ImmutableQueue < T > ImmutableQueueOf < T > ( params T [ ] items )
264264 {
265- return ImmutableQueue . Create ( items . Copy ( ) ) ;
265+ return ImmutableQueue . Create ( items ) ;
266266 }
267267}
0 commit comments