What's the correct opEquals signature for structs?
Alex Rønne Petersen
xtzgzorex at gmail.com
Tue Mar 13 15:47:42 PDT 2012
On 13-03-2012 23:35, bearophile wrote:
> Alex R. Petersen:
>
>> It was an integer in the past (believe it or not). :) equals_t made the
>> transition easier.
>
> Thank you for your answers, now I understand.
> Using an int makes sense for opEquals, because if opEquals doesn't get inlined then using int is sometimes able to give you a bit more efficiency (there is no need to convert values different from 0 and 1 to 1). I don't know how much this saves you on modern CPUs (probably no more than few CPU cycles).
>
> Bye,
> bearophile
Most compilers implement booleans as native integers and narrow/expand
them when storing/loading to/from memory, so it's unlikely to matter at all.
--
- Alex
More information about the Digitalmars-d-learn
mailing list