Re: Dort behaviour change on php7 master

From: Date: Mon, 26 Jan 2015 19:19:27 +0000
Subject: Re: Dort behaviour change on php7 master
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-81171@lists.php.net to get a copy of this message
On 01/26/2015 11:14 AM, Pascal Chevrel wrote: > Hi all, > > I just compiled master to test my main application and the good news is > that I have no functional regression and some of the views get a > considerable speed up (like, page generation divided by two!). > > I had one unit test failing and I reduced that to a simple testcase that > I put there: > > http://3v4l.org/4tGv6 > > Sorting in php master in this specific case is now different on PHP 7 > than on 5.3-5.6 (and actually different than PHP 7 at the beginning of > the month). The sorting order is now the same as HHVM. > > I think the HHVM behaviour makes more sense in this case as I don't see > why the resulting array should be reversed in this sorting case where > all lengths are equal, but on the other hand the current behaviour is > probably 10 years old and maybe it could cause bigger problems in other > apps than a unit test to update. > > Just that you know, in case it matters. Yeah, this is a known change and the documentation has had a note about not relying on the ordering of equal elements. Although the note in the manual is probably a bit too geeky. It should be more explicit and talk about the effect rather than the cause: Note: Like most PHP sorting functions, sort() uses an implementation of » Quicksort. The pivot is chosen in the middle of the partition resulting in an optimal time for already sorted arrays. This is however an implementation detail you shouldn't rely on. -Rasmus

Attachment: [application/pgp-signature] OpenPGP digital signature signature.asc
« previous php.internals (#81171) next »