From 6c32b8acc436b21e2b0d01b3ed9292b7f22caa70 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Fri, 11 Apr 2003 09:50:00 +0000 Subject: [PATCH] 2003-04-11 Dietmar Maurer * String.cs (Equals): avoid the internal call, code cleanups svn path=/trunk/mcs/; revision=13511 --- mcs/class/corlib/System/ChangeLog | 4 ++++ mcs/class/corlib/System/String.cs | 36 +++++++++---------------------- 2 files changed, 14 insertions(+), 26 deletions(-) diff --git a/mcs/class/corlib/System/ChangeLog b/mcs/class/corlib/System/ChangeLog index 5318954fff2..9da87377249 100644 --- a/mcs/class/corlib/System/ChangeLog +++ b/mcs/class/corlib/System/ChangeLog @@ -1,3 +1,7 @@ +2003-04-11 Dietmar Maurer + + * String.cs (Equals): avoid the internal call, code cleanups + 2003-04-11 Alan Tam * Convert.cs: fixed bug #41085. diff --git a/mcs/class/corlib/System/String.cs b/mcs/class/corlib/System/String.cs index fbb8139f004..db847d26946 100644 --- a/mcs/class/corlib/System/String.cs +++ b/mcs/class/corlib/System/String.cs @@ -33,10 +33,16 @@ namespace System { if (null == str1 || null == str2) return false; - if (str1.length != str2.length) + int len = str1.length; + + if (len != str2.length) return false; - return InternalEquals(str1, str2); + for (int i = 0; i < len; i++) + if (str1 [i] != str2 [i]) + return false; + + return true; } public static bool operator == (String str1, String str2) { @@ -48,33 +54,11 @@ namespace System { } public override bool Equals(Object obj) { - if ((this as object) == obj) - return true; - - if (null == obj) - return false; - - if (!(obj is String)) - return false; - - string other = (string) obj; - if (length != other.length) - return false; - - return InternalEquals(this, other); + return Equals (this, obj as String); } public bool Equals(String value) { - if ((this as object) == value) - return true; - - if (null == value) - return false; - - if (length != value.length) - return false; - - return InternalEquals(this, value); + return Equals (this, value); } [IndexerName("Chars")] -- 2.25.1