From: oliver at burtchen dot com Operating system: PHP version: 5.0.2 PHP Bug Type: Performance problem Bug description: array_key_exists() makes a copy of the given array
Description: ------------ it looks loke array_key_exists() makes a copy of the given array if there is a reference to that array. if there is no reference, everything works well. Reproduce code: --------------- // just to get the time in microseconds function getmicrotime() { list($usec, $sec) = explode(" ",microtime()); return ((float)$usec + (float)$sec); } $cnt = 2000; $a = array_fill(0, $cnt, 'foo'); // this works as aspected very fast $mtime = getmicrotime(); for ($i = 0; $cnt > $i; $i++) array_key_exists($i, $a); echo getmicrotime() - $mtime . '<br>'; $b =& $a; // making a reference, but not using it // this will take a huge amount of time, but it's the same code as above $mtime = getmicrotime(); for ($i = 0; $cnt > $i; $i++) array_key_exists($i, $a); echo getmicrotime() - $mtime . '<br>'; Expected result: ---------------- the two loops should work the same. -- Edit bug report at http://bugs.php.net/?id=30295&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=30295&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=30295&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=30295&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=30295&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=30295&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=30295&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=30295&r=needscript Try newer version: http://bugs.php.net/fix.php?id=30295&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=30295&r=support Expected behavior: http://bugs.php.net/fix.php?id=30295&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=30295&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=30295&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=30295&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=30295&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=30295&r=dst IIS Stability: http://bugs.php.net/fix.php?id=30295&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=30295&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=30295&r=float MySQL Configuration Error: http://bugs.php.net/fix.php?id=30295&r=mysqlcfg