[development] Note that PHP arrays are fast
Karoly Negyesi
karoly at negyesi.net
Tue Apr 10 00:19:26 UTC 2007
Hi,
Note my trick in http://drupal.org/node/134697 which shows that the hash
lookups in Zend Engine are a bit faster than branching.
Instead of
$class = $class == 'even' ? 'odd' : 'even'
we have
$flip = array('even' => 'odd', 'odd' => 'even');
$class = $flip[$class];
The first can be as much as 10% slower. I will explore this area further
and I recommend everyone to familiarize themselves with the vast array of
php array functions :) because next Drupal will be even more abound with
arrays.
Regards,
NK
More information about the development
mailing list