Hi there
Thanks for Elevate, it's a great project.
I'd like to submit a tiny improvement on the Memoize function. I often
use this extension with T as System.String. However in my case these
strings are case insensitive.
Therefore supplying an IEqualityComparer<T> to the Dictionary built
into Memoize() seems to be a good idea, since it may reduce the number
of memoizations stored in cache.
Here is my scenario (unit test) :
>> Func<string, object> func = x => new Object();
>> var memoized = func.Memoize(StringComparer.OrdinalIgnoreCase);
>> Assert.IsTrue(Object.ReferenceEquals(memoized("hello"), memoized("HELLO")));
With :
>> public static Func<T, TResult> Memoize<T, TResult>(this Func<T, TResult> func, IEqualityComparer<T> comparer)
>> {
>> // (...)
>> var table = new Dictionary<T, TResult>(comparer);
>> // (...)
>> }
I hope this may be useful for other people.
On Sep 21, 11:51 pm, "
cmmari...@gmail.com" <
cmmari...@gmail.com>
wrote: