int opEquals(Object), and other legacy ints
Bruno Medeiros
brunodomedeirosATgmail at SPAM.com
Thu Jul 27 11:33:16 PDT 2006
Walter Bright wrote:
> Bruno Medeiros wrote:
>> Walter Bright wrote:
>>> Stewart Gordon wrote:
>>>> There seem to be a number of leftovers from before we had a bool
>>>> type, and many people were using the int type to pass booleans around.
>>>
>>> They are typed as returning int for efficiency reasons. These
>>> functions often appear in performance critical loops, where an extra
>>> instruction or two makes a difference.
>>
>> But isn't bool an int internally? Why is it less efficient to use a bool?
>
> It's a byte internally, and is constrained to be one of the values 0 or 1.
Duh, it's a byte of course, I should have checked that.
But the question remains, is it then less efficient to return a byte
than a int? Why? And if so isn't there a way for the compiler to somehow
optimize it?
I find it a bit hard to believe that nowadays there isn't sufficient
compiler and/or CPU technology to somehow make a bool(byte) return value
as efficient as a int one. :/
--
Bruno Medeiros - CS/E student
http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D
More information about the Digitalmars-d-bugs
mailing list