Speaking of PHP, I would like to ask if there is a performance difference between the two:
$name=($IsBoy)?"George":"Mary";
vs
if($IsBoy) { $name="George"; } else { $name="Mary"; }
Will these two results work with a different opcode?
If so, will there be any theoretical performance difference? (of course, ignore the time when these two should be read / compiled / interpreted)
If yes, then optimizers, such as the zend optimizer, will take advantage of this and do any re-layouts automatically?
ps if you think my code for "full-longhand" if-then-else is too complicated, provide an example of the most basic code and the answer to it.
UPDATE:
I was hoping the question was perfectly clear, but it seems people are not getting the message. This question relates to a THEORETICAL (... but real and mesaureable) performance difference (which is why I applied bold and italics to a theoretical one ). Please do not answer by saying that the programming style is more readable and that it is too annoying to worry about performance.
ps 2: paying special attention to the theoretical word, I try to prevent answers like "donβt worry that itβs not worth the trouble, its just nanoseconds."
source share