Re: array_values should be a no-op for packed layout arrays
| From: | Sara Golemon | Date: | Tue, 14 Mar 2017 23:39:02 +0000 |
| Subject: | Re: array_values should be a no-op for packed layout arrays | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-98527@lists.php.net to get a copy of this message | ||
On Tue, Mar 14, 2017 at 6:25 PM, Jesse Schalken <me@jesseschalken.com> wrote:
> I didn't realise packed arrays could still have gaps. If that's the case,
> why can't [12=>'foo', 42=>'bar'] be packed (index 0-11 and 13-41
> are
> undefined)?
>
It can be, but in practice isn't likely to be since that's a lot of
empty space for a two element array. It will end up mixed pretty
quickly before you get to that point.
> I agree checking if the array is both packed and without gaps would still
> make a worthwhile optimisation.
>
Oh yeah, btw... six hours ago...
https://github.com/php/php-src/commit/c74bc87c74f48bc55541b3bf2fc67d595f58a3b5
-Sara