[TYPO3-core] RFC #13998: Introduce Automatic versioning of CSS and JS files
Jigal van Hemert
jigal at xs4all.nl
Wed Apr 7 09:37:57 CEST 2010
Lars Houmark wrote:
>> could be just a $seperator = ($lookupFile[1]) ? '&' : '?';
>> IMO this is also faster
>
> Maybe I did not understand the benchmarking of Jigal correctly, but else
> will be the most common situation in this statement, and according to
> him that is slower than having a normal if / else. I will keep it like
> this for now, unless someone thinks it should be changed. I also like
> ternary more myself so... :)
In a lot of cases you see something like
$var .= (condition) ? 'value' : '';
I compared the speed of this with
if (condition) {
$var .= 'value';
}
If the condition is true the ternary operator was a few percent slower
(not significantly IMO) than the if statement.
If the condition is false the ternary operator was 30-40% slower than
the if statement.
If the condition is a check for TYPO3_MODE == 'BE', it is very likely
that the condition is almost always false. There is no operation in
those cases and the ternary operator can only slow down the frontend.
Summary:
- the ternary operator is not faster than an if (-else) statement
- if either of the actions of the ternary operator results in no
operation, the ternary operator is significantly slower for that action
than an if statement
--
Jigal van Hemert
* please review #13940 *
More information about the TYPO3-team-core
mailing list