[ros-dev] Replacing unsafe TRUE comparisons (Following Re: bool => BOOL)

Timo Kreuzer timo.kreuzer at web.de
Sat Nov 15 22:22:36 UTC 2014


Am 14.11.2014 15:32, schrieb Love Nystrom:
>
> On 2014-11-14 00.41, Alex Ionescu wrote:
>> I would much rather see if (f != FALSE) instead of if ( f ).
>
> Well, it's certainly a valid option, and C++ compilers seem to generate
> the same "CMP  boolRm, 0" in both cases (though the latter could actually
> generate the potentially faster and better "OR  boolRm, boolRm" instead).
"if (f != FALSE)" and "if (f)" are exactly 100% the same for the 
compiler. "if (f)" is nothing but a synonym for "if (f != 0)" and FALSE 
is 0. Whether it creates a CMP, or an OR or a TEST is all up to the 
compiler and it will be the same in both cases. If it was not the same, 
there is something ... well not neccessarily "wrong" but at least very 
strange with the compiler.

>
> I expect some people will use the former.
> Personally I much prefer the latter.
I think both have their pros and cons. So I don't really care.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.reactos.org/pipermail/ros-dev/attachments/20141115/8d4400c6/attachment.html>


More information about the Ros-dev mailing list