Just found an unnecessary null check in KeyedCollection.Contains(TKey).
Appreciate it's only a very small optimization, but shouldn't thought this sort of inefficiency be picked up by an automated code analysis tool?
Here's the C# generated by reflector:
public bool Contains(TKey key)
{
if (key == null)
{
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.key);
}
if (this.dict != null)
{
return this.dict.ContainsKey(key);
}
if (key != null) // Not needed as key cannot be null
{
foreach (TItem local in base.Items)
{
if (this.comparer.Equals(this.GetKeyForItem(local), key))
{
return true;
}
}
}
return false;
}
Also, what's the best way of sending in a patch? ;-) Through the .net forums or ?