Author: raja
Date: 2007-05-02 05:26:21 -0400 (Wed, 02 May 2007)
New Revision: 76556

Modified:
   trunk/mcs/class/System/System.Collections.Generic/ChangeLog
   trunk/mcs/class/System/System.Collections.Generic/SortedDictionary.cs
Log:
* SortedDictionary.cs (ICollection.Contains): Use EqualityComparer
for comparing the value field.


Modified: trunk/mcs/class/System/System.Collections.Generic/ChangeLog
===================================================================
--- trunk/mcs/class/System/System.Collections.Generic/ChangeLog 2007-05-02 
08:34:15 UTC (rev 76555)
+++ trunk/mcs/class/System/System.Collections.Generic/ChangeLog 2007-05-02 
09:26:21 UTC (rev 76556)
@@ -1,5 +1,8 @@
 2007-05-02  Raja R Harinath  <[EMAIL PROTECTED]>
 
+       * SortedDictionary.cs (ICollection.Contains): Use EqualityComparer
+       for comparing the value field.
+
        * RBTree.cs (do_remove): Remove some redundant assignments/checks.
        (NodeEnumerator): Simplify.  Keep track of a list of
        right-pennants that need to be traversed next, rather than

Modified: trunk/mcs/class/System/System.Collections.Generic/SortedDictionary.cs
===================================================================
--- trunk/mcs/class/System/System.Collections.Generic/SortedDictionary.cs       
2007-05-02 08:34:15 UTC (rev 76555)
+++ trunk/mcs/class/System/System.Collections.Generic/SortedDictionary.cs       
2007-05-02 09:26:21 UTC (rev 76556)
@@ -257,8 +257,9 @@
 
                bool ICollection<KeyValuePair<TKey,TValue>>.Contains 
(KeyValuePair<TKey,TValue> item)
                {
-                       Node n = (Node) tree.Lookup (item.Key);
-                       return n != null && item.Value.Equals (n.value);
+                       TValue value;
+                       return TryGetValue (item.Key, out value) &&
+                               EqualityComparer<TValue>.Default.Equals 
(item.Value, value);
                }
 
                bool ICollection<KeyValuePair<TKey,TValue>>.IsReadOnly {
@@ -268,11 +269,9 @@
                bool ICollection<KeyValuePair<TKey,TValue>>.Remove 
(KeyValuePair<TKey,TValue> item)
                {
                        TValue value;
-                       if (TryGetValue (item.Key, out value)) {
-                               if (EqualityComparer<TValue>.Default.Equals 
(item.Value, value))
-                                       return Remove (item.Key);
-                       }
-                       return false;
+                       return TryGetValue (item.Key, out value) &&
+                               EqualityComparer<TValue>.Default.Equals 
(item.Value, value) &&
+                               Remove (item.Key);
                }
 
                #endregion

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to