Remove `this == null` checks from string.Equals (dotnet/coreclr#9768)
authorJames Ko <jamesqko@gmail.com>
Sat, 25 Feb 2017 06:48:36 +0000 (01:48 -0500)
committerJan Kotas <jkotas@microsoft.com>
Sat, 25 Feb 2017 06:48:36 +0000 (22:48 -0800)
Commit migrated from https://github.com/dotnet/coreclr/commit/b5b8b1096171ffecfa0a7c1e643cae6cabd16a23

src/coreclr/src/mscorlib/src/System/String.Comparison.cs

index 54dc086..d35e900 100644 (file)
@@ -850,9 +850,6 @@ namespace System
         // Determines whether two strings match.
         public override bool Equals(Object obj)
         {
-            if (this == null)                        // this is necessary to guard against reverse-pinvokes and
-                throw new NullReferenceException();  // other callers who do not use the callvirt instruction
-
             if (object.ReferenceEquals(this, obj))
                 return true;
 
@@ -870,9 +867,6 @@ namespace System
         [Pure]
         public bool Equals(String value)
         {
-            if (this == null)                        // this is necessary to guard against reverse-pinvokes and
-                throw new NullReferenceException();  // other callers who do not use the callvirt instruction
-
             if (object.ReferenceEquals(this, value))
                 return true;
 
@@ -1231,4 +1225,4 @@ namespace System
         [Pure]
         public bool StartsWith(char value) => Length != 0 && m_firstChar == value;
     }
-}
\ No newline at end of file
+}