[TYPO3-core] RFC #11718: speed up function t3lib_iconWorks::skinImg()

Michael Stucki michael at typo3.org
Fri Aug 14 19:24:24 CEST 2009


Hi Rupi,

Rupert Germann schrieb:
>> I'm especially refering to lines 30-33 in v4 where you added
>> parantheses that weren't there before.
> 
> CGL says (page 11):
> Ternary conditional operator must be used only if it has two outcomes.
> Example:
> $result = ($useComma ? ',' : '.');
> 
> so I added parantheses around the complete condition

Oh, what a shame! :-( Indeed you are right, at least that's what the
current CGL says.

I'm not sure if this change was really intended because in the past the
practice was different, and I can't remember that anyone noticed or
discussed this change.

Anyway, I reverted my "fix" and will bring up the topic at a later point...

>> Stucki, who's just sitting next to me, did also notice this issue and
>> is going to fix it in a minute.
> 
> thanks Stucki, but now it looks like this:
> $result = ($useComma) ? ',' : '.';
> 
> why is this better than the parantheses around the complete condition ?

Because it distincts the condition from the rest of the line.
Here is a better example:

$result = ($input + 5 < 10) ? 20 : 0;

vs.

$result = ($input + 5 < 10 ? 20 : 0);

Greetings, Michael
-- 
Use a newsreader! Check out
http://typo3.org/community/mailing-lists/use-a-news-reader/


More information about the TYPO3-team-core mailing list