Possible Duplicate:
Speed difference between If-Else and Ternary operator in C�
This is a very simple question, does the ternary operator increase the speed of execution in comparison to if else statement?
Possible Duplicate:
Speed difference between If-Else and Ternary operator in C�
This is a very simple question, does the ternary operator increase the speed of execution in comparison to if else statement?
No. Most languages parse it to a very similar syntax tree. Any jit/optimizer is going to collapse it into 'basic blocks' of simple instructions without jumps; and from that point on it will optimize the same.
There could, of course, be some really bad systems out there for which this is not true; but gcc/msvc/c# will all deal with it equally well.
It's abundance can usually be associated with the fact that it is an expression instead of just a logic statement. This makes it all to easy to do things like (note: really ugly example ahead):
size_t n = strlen( pszVar == NULL ? "" : pszVar );