Skip to content

Commit ce7250f

Browse files
authored
Use List for Memoize's cache (performance)
Indexing into an IList<> requires an interface call, and can't be inlined. Since the cache field is private, there is no reason to not type it instead as List<>, thus get a free performance gain at no cost. Closes morelinq#546
1 parent f019748 commit ce7250f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

MoreLinq/Experimental/Memoize.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public static IEnumerable<T> Memoize<T>(this IEnumerable<T> source)
6262

6363
sealed class MemoizedEnumerable<T> : IEnumerable<T>, IDisposable
6464
{
65-
IList<T> _cache;
65+
List<T> _cache;
6666
readonly object _locker;
6767
readonly IEnumerable<T> _source;
6868
IEnumerator<T> _sourceEnumerator;

0 commit comments

Comments
 (0)