2010-03-03 Rodrigo Kumpera <rkumpera@novell.com>
authorRodrigo Kumpera <kumpera@gmail.com>
Thu, 4 Mar 2010 02:17:54 +0000 (02:17 -0000)
committerRodrigo Kumpera <kumpera@gmail.com>
Thu, 4 Mar 2010 02:17:54 +0000 (02:17 -0000)
* Type.cs (Equals): Better version that does less
trips to runtime land.

svn path=/trunk/mcs/; revision=152988

mcs/class/corlib/System/ChangeLog
mcs/class/corlib/System/Type.cs

index 0b3a39aeb50e5c755ab96f58ccb93aaf92a95c3a..5ef7ec6093e083f435313fd7cbecdd051303c275 100644 (file)
                //
                // And we have a patch for that called (trim
 
+2010-03-03 Rodrigo Kumpera  <rkumpera@novell.com>
+
+       * Type.cs (Equals): Better version that does less
+       trips to runtime land.
+
 2010-03-03 Rodrigo Kumpera  <rkumpera@novell.com>
 
        * MonoType.cs: Add v4 security properties.
index d4ef329aba038a61607e5ddfe7bcfc77c9869859..12ff169359e63b0bf807290fba1e5c0bf370fe7b 100644 (file)
@@ -435,13 +435,27 @@ namespace System {
 #if NET_4_0
                public virtual bool Equals (Type o)
                {
+                       if ((object)o == this)
+                               return true;
+                       if ((object)o == null)
+                               return false;
+                       Type me = UnderlyingSystemType;
+                       if ((object)me == null)
+                               return false;
+
+                       o = o.UnderlyingSystemType;
+                       if ((object)o == null)
+                               return false;
+                       if ((object)o == this)
+                               return true;
+                       return me.EqualsInternal (o);
+               }               
 #else
                public bool Equals (Type o)
                {
 
                        if (o == this)
                                return true;
-#endif
                        if (o == null)
                                return false;
                        Type me = UnderlyingSystemType;
@@ -449,7 +463,7 @@ namespace System {
                                return false;
                        return me.EqualsInternal (o.UnderlyingSystemType);
                }
-
+#endif
 #if NET_4_0
                [MonoTODO ("Implement it properly once 4.0 impl details are known.")]
                public static bool operator == (Type left, Type right)