array_values should be a no-op for packed layout arrays
| From: | Jesse Schalken | Date: | Mon, 13 Mar 2017 05:34:40 +0000 |
| Subject: | array_values should be a no-op for packed layout arrays | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-98515@lists.php.net to get a copy of this message | ||
I noticed this commit
<https://github.com/facebook/hhvm/commit/4167d66fcfa81a1c2a19e853282fac968d9cd454>
recently in HHVM, which makes array_values() return the same array back if
it's packed instead of building a copy.
My understanding is PHP 7 also has packed arrays like HHVM, and my reading
of PHP's array_values() implementation (here
<https://github.com/php/php-src/blob/c6982995504b6e21e8a5ade29cfb16a55196dc43/ext/standard/array.c#L4000>)
is that it always creates a copy of the array, even if it's packed.
Would this be a worthwhile optimisation to make in PHP as well?