Please remove ?:

Lionello Lunesu lio at lunesu.remove.com
Fri Jun 2 08:02:15 PDT 2006


dennis luehring wrote:
> Lionello Lunesu schrieb:
>> I just run accross the following code at my work:
>>
>> #  NoWallCheck?value=_T("0"):value=_T("1");
>>
>> Took at least a minute to figure out what was going on.
> 
> same like
> 
> value = NoWallCheck ? _T("0") : _T("1");
> 
> think of printf("%s",bBool ? "true" : "false");

I admit it's handy, but it should be limited to constants or something. 
In that case the compiler could also use a small look-up table for the 
two values, to get rid of the jmp instruction.

> 
>  > It's useless
> it is handy

It's sugar, nothing more. D should be RISC :)

> 
>> slow 
> ???

?: always results in a jump instruction. My knowledge of performance 
penalties dates back to the 486 era, so it _might_ not be that big a 
deal now with branch prediction and what not.

L.



More information about the Digitalmars-d mailing list