Re: More packed hash optimizations in array.c
| From: | Xinchen Hui | Date: | Tue, 02 Aug 2016 04:45:18 +0000 |
| Subject: | Re: More packed hash optimizations in array.c | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-94793@lists.php.net to get a copy of this message | ||
Hey
On Thu, Jul 28, 2016 at 4:59 PM, Benjamin Coutu <ben.coutu@zeyos.com> wrote:
> Hello Xinchen,
>
> I have noticed two more cases where we could easily use packed arrays.
>
> 1. array_merge($packed1, $packed2, ...):
>
> In the quite common case where all arguments are packed arrays, the
> resulting array can also be a packed array (as per documentation: "if the
> input arrays [...] contain numeric keys, the later value will not overwrite
> the original value, but will be appended"), thereby ensuring that packed
> arrays stay packed when appended to one another.
> In general we should try to preserve the packed characteristics wherever
> possible.
>
I will need do some benchmark, as it is already very simple implementation
now.
>
> 2. array_column($input, $column_key, $index_key=null):
>
> For the common case when $index_key=null, we can just create a packed
> array.
> Also (not related to packing), we could pre-initialize the return_value
> array size with array_init_size() if, and only if, $column_key=null.
>
this one is committed here:
https://github.com/php/php-src/commit/fea2042a47dbda7210306c881a9f0a82b8503a45
thanks
>
> Please let me know your thoughts.
>
> Thanks,
>
> Ben
>
> --
>
> Bejamin Coutu
> ben.coutu@zeyos.com
>
> ZeyOS, Inc.
> http://www.zeyos.com
>
>
--
Xinchen Hui
@Laruence
http://www.laruence.com/