On opCmp

Steven Schveighoffer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Mar 2 13:29:41 PST 2015


On 3/2/15 8:52 AM, "Nordlöw" wrote:
> On Friday, 27 February 2015 at 15:00:35 UTC, Steven Schveighoffer wrote:
>> Hm... what about:
>>
>> return count < rhs.count ? -1 : count > rhs.count ? 1 : rank <
>> rhs.rank ? -1 : rank > rhs.rank;
>
> Is this more efficient than my version?

You said "more compact", not more efficient :)

But I think they are probably the same generated code. I'm not doing 
anything really different (except for the shortcut for rank > rhs.rank 
being 1 or 0 based on the conversion to int).

-Steve


More information about the Digitalmars-d-learn mailing list