[TYPO3-core] RFC: Feature Request 6037: Performance tunning in t3lib_div by removing elderly PHP functions
ingmar at typo3.org
Sun Aug 19 14:42:02 CEST 2007
Oliver Hader wrote:
> There are some old-styled PHP functions in t3lib_div which could be done
> in a better way nowadays. Those among are:
> * while(list($k, $v)=each($arr)) --> foreach ($arr as $k => &$v)
> * strstr($haystack, $needle) --> strpos($haystack, $needle)
Generally: Good stuff. I think a simple foreach loop looks much nicer
than the while(list()=each()) construct.
> Use the mentioned PHP functions to get a better performance.
> Use references in foreach loops for a better performance (requires
> PHP5), but this is the requirement for TYPO3 4.2 - thus, it's okay.
I'm against using references in foreach loops where they are not necessary.
Are you sure they improve performance? I've read that references are
actually *slower*, as PHP is faster at copying variables than at
referencing them. When you copy a variable in PHP it actually makes only
a reference as well and only when you write to the new variable, it
behaves like a copy (so called COW; Copy On Write). If your performance
tests yield other results, I'd be interested to hear about it.
More information about the TYPO3-team-core