Bool type - can't it be zero / nonzero?
Chris Wright
dhasenan at gmail.com
Sun Jun 8 07:08:42 PDT 2008
celopmuh wrote:
> From what I gathered, the inconsistency in using bool/int types is for the sake of optimization, and int logical values work faster mainly because they're 0 / non-0, not 0/1 (so that you can use simple subtraction to compare things).
The inconsistency is a compiler-specific optimization: dmd, I believe,
generates slow code for dealing with bools, so Walter made
Object.opEquals return an int.
There's faster code available for dealing with bool comparisons that
make them at least as fast as the integer equivalents. It's been on the
newsgroup once or twice.
More information about the Digitalmars-d
mailing list