X[]==Y[] is 7X slower than it should be -- why?

Tomas Lindquist Olsen tomas at famolsen.dk
Sat Jun 21 09:58:34 PDT 2008


Sean Kelly wrote:
> == Quote from Jarrett Billingsley (kb3ctd2 at yahoo.com)'s article
>> "Sean Kelly" <sean at invisibleduck.org> wrote in message
>> news:g3gtvk$1tm7$1 at digitalmars.com...
>>> Done :p
>>>
>>> http://dsource.org/projects/tango/changeset/3651
>> In _adCmp,
>> if (a1.ptr == a2.ptr)
>>     return 0;
>> erm, that's not right at all.  Two slices with the same pointer and
>> different lengths.
> 
> Darnit, you're right.  Good catch.
> 
> 
> Sean

After having a look at this I don't see how it could work.
The TypeInfo passed to _adEq/Cmp is the *element* typeinfo, not the *array* typeinfo.

With the current code, the way I read it, only arrays with elementsize==1 will work (and only 
if the element is not a 1byte struct that overloads the comparison operators.

Am I missing something or should the compilers not be changed to pass the *array* typeinfo if 
these optimizations are to make any sense ?

Tomas



More information about the Digitalmars-d mailing list