[Mono-list] string equals method

Daniel Lo Nigro lists at dan.cx
Wed May 22 21:57:58 UTC 2013


Ah okay - I didn't know about the SSCLI source other than the fact it
exists, I've never used it or read its license myself. In that case I'd say
to look at Mono's implementation. It should be similar enough.

---
Regards,
Daniel

Sent from my phone - please excuse any typos.
On 23/05/2013 12:12 AM, "Alan" <alan.mcgovern at gmail.com> wrote:

> If you look at that source you cannot contribute to mono. The licenses are
> not compatible.
>
> Alan
>
> On 21 May 2013 19:00, Daniel Lo Nigro <lists at dan.cx> wrote:
>
>> The .NET question is easy to answer by using Reflector/ILSpy/or similar.
>>
>> The source code for String is probably in the SSCLI source which
>> Microsoft have publicly released.
>>
>>
>> On Wed, May 22, 2013 at 8:34 AM, Danny <dgortonii at gmail.com> wrote:
>>
>>> The mono question is easy to answer by looking at their sources.  The
>>> .NET question is easy to answer by using Reflector/ILSpy/or similar.  I
>>> won't answer the .NET question here b/c I don't want to cause any IP issues
>>> with posting .NET internal information on a mono site.
>>>
>>>
>>> On 05/21/2013 06:25 PM, Edward Ned Harvey (mono) wrote:
>>>
>>>> Msdn says string.Equals() overrides the string == operator.
>>>>
>>>> Msdn also says it's an ordinal comparison, blah blah.
>>>>
>>>> The thing I'd like to know:  Ordinal string comparison tends to be an
>>>> expensive thing to do.  This can be skipped under certain circumstances,
>>>> such as, if ReferenceEquals returns true, or if the two string length's
>>>> are different.
>>>>
>>>> Can anybody authoritatively say, under the hood, that .Net or mono
>>>> actually do this sort of acceleration in the string.Equals() method?
>>>>
>>>> public static bool operator ==( string a, string b)
>>>>
>>>> {
>>>>
>>>>                  if ( Object.ReferenceEquals(a,b) )
>>>>
>>>>                                  return true;
>>>>
>>>>                  else
>>>>
>>>>                  {
>>>>
>>>>                                  if ( a.Length != b.Length )
>>>>
>>>>                                                  return false;
>>>>
>>>>                                  else
>>>>
>>>>                                  {
>>>>
>>>>                                                  for ( int i=0;
>>>> i<a.Length ; i++ )
>>>>
>>>>                                                                  if (
>>>> a[i] != b[i] )
>>>>
>>>>
>>>>          return false;
>>>>
>>>>                                                  return true;
>>>>
>>>>                                  }
>>>>
>>>>                  }
>>>>
>>>> }
>>>>
>>>>
>>>>
>>>> ______________________________**_________________
>>>> Mono-list maillist  -  Mono-list at lists.ximian.com
>>>> http://lists.ximian.com/**mailman/listinfo/mono-list<http://lists.ximian.com/mailman/listinfo/mono-list>
>>>>
>>>>  ______________________________**_________________
>>> Mono-list maillist  -  Mono-list at lists.ximian.com
>>> http://lists.ximian.com/**mailman/listinfo/mono-list<http://lists.ximian.com/mailman/listinfo/mono-list>
>>>
>>
>>
>>
>> _______________________________________________
>> Mono-list maillist  -  Mono-list at lists.ximian.com
>> http://lists.ximian.com/mailman/listinfo/mono-list
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-list/attachments/20130523/5b39c6e5/attachment.html>


More information about the Mono-list mailing list