On 07/19/2016 12:00 PM, Ali Çehreli wrote:
> On 07/19/2016 10:41 AM, deadalnix wrote:

>> if(i < other.i) return -1;
>> if(i > other.i) return 1;
>>
>> Should be
>>
>> (i > other.i) - (i < other.i)
>>
>> Surprisingly, LLVM was unable to optimize one into the other in my tests.

If you mean the following, it's slower with ldc:

        const r = (i > other.i) - (i < other.i) ;
        if (r) return r;

> Additionally, the string may be traversed twice in opCmp. The following
> change makes D example faster:
>
>          import std.algorithm : cmp;
>          return cmp(s, other.s);
> //        return s < other.s
> //            ? -1
> //            : (s > other.s ? 1 : 0);

Faster with dmd but has no difference with ldc.

Ali

Reply via email to