[TYPO3-dev] FYI: comparing execution speed of some php functions

Niels Pardon mail at niels-pardon.de
Fri Jun 26 19:41:33 CEST 2009


Hi Rupert!

Rupert Germann schrieb:
> That means even if I have something like this in my code:
> 
> while(list($key) = each($arr)) {
>   // do smthg that needs only $key
> }
>  
> it will be way slower than:
> 
> foreach($arr as $key => $val) {
>   // do smthg that needs only $key
> }
> 
> although $val is never used.

What about comparing it to something like this?

foreach (array_keys($arr) as $key) {
	// do smthg that needs only $key
}

I think I saw that somewhere in an extension's code.

> If I count the occurences of "while(list(" in class tslib_content I see some
> potential here.
> 
> (FYI: the patch for class tslib_content is almost ready)

If you like I could join you in replace all "while(list(" occurences
with foreach() in the core.

Greets,

Niels




More information about the TYPO3-dev mailing list