[development] Note that PHP arrays are fast

Bèr Kessels ber at webschuur.com
Tue Apr 10 07:41:07 UTC 2007

Its slightly off topic, buw while we are at it, I benchmarked if ($foo) 
{bar()} versus $foo ? bar () : null;

Op dinsdag 10 april 2007 08:20, schreef Jakob Petsovits:
> Just out of interest, what's with
> if ($class !== 'even') {
>     $class = 'odd';
> }

if ($foo) {
is about 7% faster then 
$foo ? $bar : null; 
The reason is, obviously, that the second always needs an else. And if() else 
statement is just as fast as the $foo? : ; way. 
We should avoid $foo ? checks that need no else at all costs, imo.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.drupal.org/pipermail/development/attachments/20070410/73125323/attachment-0001.pgp 

More information about the development mailing list