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

torhu no at spam.invalid
Sun Jun 22 12:04:41 PDT 2008


Jarrett Billingsley wrote:
> "torhu" <no at spam.invalid> wrote in message 
> news:g3katb$14ee$1 at digitalmars.com...
>> downs wrote:
>>> Sean Kelly wrote:
>>>> Are the braces really necessary for the comparison though?  I'd just do 
>>>> "X == Y."
>>>> I wouldn't expect a speed difference, but the cycle count has be 
>>>> wondering if
>>>> by adding the braces the generated code is cloning the arrays before 
>>>> comparing
>>>> them or something like that.
>>>>
>>> No, array[] is just the full slice, i.e. the equivalent of [0 .. $].
>>>
>>> It's useful for static arrays, as it effectively turns them into dynamic 
>>> ones.
>>>
>> I wish you didn't say that.  Yet another undocumented feature to try to 
>> remember?
> 
> It's not undocumented.  Look at the first slicing example here: 
> http://www.digitalmars.com/d/1.0/arrays.html 
> 
> 
I guess I was just a bit too tired when posting.  It doesn't turn them 
into dynamic arrays, it's still just a slice into a static array. 
Anyway, value comparison is defined to be the same for both static and 
dynamic arrays.



More information about the Digitalmars-d mailing list