[Mono-devel-list] Patch for String.Equals

Ben Maurer 05mauben at hawken.edu
Mon Apr 5 07:43:07 EDT 2004


To optimize for both platforms, the native integer size should be used.
You can do this by casting the char* to a void**, and using
string.Length * sizeof (char*) / sizeof (void**).

The first char of a string is always going to be aligned to a dword
boundry, because of how the object is layed out. I am not sure if on a
64 bit it would be qword algigned.

-- Ben

>>> Michal Moskal <malekith at pld-linux.org> 04/05/04 07:33 AM >>>
On Sun, Apr 04, 2004 at 07:48:52PM -0400, Ben Maurer wrote:
> Hello,
> 
> This is very interesting. Am going to look into the assembly we
generate
> to see if this is the best we can do.
> 
> I am a bit unsure about the long compares, what do they gain us?
> Internally, they are just two int compares.

x86-64 anyone?

However the problem with comparing strings as ints -- are they properly
aligned? Using unaligned access on x86 slows things down, and on ppc
it AFAIR generates an exception.

-- 
: Michal Moskal :: http://www.kernel.pl/~malekith :: GCS !tv h e>+++ b++
: When in doubt, use brute force. -- Ken Thompson :: UL++++$ C++ E--- a?
_______________________________________________
Mono-devel-list mailing list
Mono-devel-list at lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list




More information about the Mono-devel-list mailing list