blob: 09fa4608ff6d590630be5c616c5c93a8673ed149 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Collections.Generic;
namespace Internal.LowLevelLinq
{
internal static partial class LowLevelEnumerable
{
public static List<T> ToList<T>(this IEnumerable<T> source)
{
List<T> result;
var collection = source as ICollection<T>;
if (collection != null)
result = new List<T>(collection.Count);
else
result = new List<T>();
foreach (var element in source)
result.Add(element);
return result;
}
}
}
|