ID: 47643
Comment by: emiel dot bruijntjes at copernica dot com
Reported By: viper7 at viper-7 dot com
Status: Assigned
Bug Type: Performance problem
Operating System: *
PHP Version: 5.*, 6CVS (2009-04-13)
Assigned To: felipe
New Comment:
This bug is now open for 10 months. Are you still working on this?
Previous Comments:
------------------------------------------------------------------------
[2009-07-09 20:38:20] jani@php.net
As Dmitry's noted, this is side-effect your fix caused.
------------------------------------------------------------------------
[2009-07-01 15:32:01] dmitry@php.net
The problems occurs because of "bad" patch for bug #42838.
The diff algorithm sorts arrays using qsort and then assumes that they
are sorted correctly. But in case of user compaison function it can't be
guaranteed. Thus in ext/standard/tests/array/bug42838.phpt
key_compare_func() can't sort array correctly because expressions (0 <
'a') and (0 > 'a') both false ('a' is interpreted as a number 0).
It should be fixed in some way
------------------------------------------------------------------------
[2009-06-30 15:22:24] derick@php.net
Dmitry, could you have a look? I have no idea why this occurs.
------------------------------------------------------------------------
[2009-06-30 15:19:43] viper7 at viper-7 dot com
I've tracked down the change that broke things, this is it. but the
exact reason is beyond me heh. Hopefully this helps.
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.308.2.21.2.51&r2=1.308.2.21.2.52&pathrev=PHP_5_2
------------------------------------------------------------------------
[2009-03-24 21:19:01] cisa at cisa85 dot de
Like I described [1] I use this function to get the performance I
need:
function array_diff_fast($data1, $data2) {
$data1 = array_flip($data1);
$data2 = array_flip($data2);
foreach($data2 as $hash => $key) {
if (isset($data1[$hash])) unset($data1[$hash]);
}
return array_flip($data1);
}
Thanks to Viper for his help.
[1]
http://nohostname.de/blog/2009/03/24/bug-gefunden-array_diff-in-php-526-unglaublich-langsam/
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/47643--
Edit this bug report at http://bugs.php.net/?id=47643&edit=1