[TYPO3-core] RFC: Feature Request 6037: Performance tunning in t3lib_div by removing elderly PHP functions

Oliver Hader oh at inpublica.de
Sun Aug 19 19:39:59 CEST 2007

Hi Ingmar,

Ingmar Schlecht schrieb:
> Oliver Hader wrote:
>> Solution:
>> 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.

You're right. I've also tested this again. It shows, that the regular
disposal without references is a bit faster. But, as you also mentioned,
the advantages of references is when you modify an array item or put it
to another function. In TYPO3 addSlashesOnArray() and
stripSlashesOnArray() might call themselves recursively and benefit from
the referencing.

Furthermore references are a bit faster if working with arrays, e.g.
$tca =& $GLOBALS['TCA']['tt_content']['columns']['bodytext']
is faster than using it without reference, e.g.
$tca = $GLOBALS['TCA']['tt_content']['columns']['bodytext'].

If found other recources on the web which state that
"while(list(,$value)=each($array))" would be faster than calling
"foreach ($array as $value)". But I could not reproduce this with PHP5
and the profiler of the PEAR extension "Benchmark".

I've created a new patch. See attachment.

Oliver Hader
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0006037_v2.patch
Type: text/x-patch
Size: 19820 bytes
Desc: not available
Url : http://lists.netfielders.de/pipermail/typo3-team-core/attachments/20070819/d41fc686/attachment-0001.bin 

More information about the TYPO3-team-core mailing list