General Discussion

1 view
Skip to first unread message

cmma...@gmail.com

unread,
Sep 21, 2009, 5:51:43 PM9/21/09
to Elevate Project
Here's a thread for general discussion. Let us know what you think of
the existing project and how we can improve.

beoneTristar

unread,
Oct 14, 2009, 7:21:13 AM10/14/09
to Elevate Project
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:
Reply all
Reply to author
Forward
0 new messages