From:             bugs dot php dot net at nanonanonano dot net
Operating system: Linux
PHP version:      5CVS-2006-05-23 (snap)
PHP Bug Type:     Performance problem
Bug description:  array_key_exists performance is poor for &$array

Description:
------------
If there is a reference taken to an array ($b =& $a) then the performance
of array_key_exists($foo, $a) drops off enormously unless
array_key_exists($foo, &$a) is used.

(Note this is identical to #30295 which is marked as fixed in CVS but
doesn't appear to be fixed at all: it is found in both 4CVS and 5CVS)

Reproduce code:
---------------
Based on the code in bug #30295:

    http://pastebin.com/733286

Expected result:
----------------
Time for the following operations should be approximately the same:

array_key_exists($i, $a);

$b =& $a; array_key_exists($i, $a);

$b =& $a; array_key_exists($i, &$a);

Actual result:
--------------
Time for 

$b =& $a; array_key_exists($i, $a);

is significantly greater than for the others.

Sample times from running the reproduce code:

Test with no refs:                    0.0012528896331787
Test with a ref to the array:         0.78344106674194
Test with a ref to the array and pass by ref: 0.0019340515136719


-- 
Edit bug report at http://bugs.php.net/?id=37563&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=37563&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=37563&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=37563&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=37563&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=37563&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=37563&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=37563&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=37563&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=37563&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=37563&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=37563&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=37563&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=37563&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=37563&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=37563&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=37563&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=37563&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=37563&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=37563&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=37563&r=mysqlcfg

Reply via email to