Re: More packed hash optimizations in array.c
| From: | Benjamin Coutu | Date: | Wed, 03 Aug 2016 22:00:00 +0000 |
| Subject: | Re: More packed hash optimizations in array.c | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-94818@lists.php.net to get a copy of this message | ||
Hello Xinchen,
Thanks for changing array_pad and array_rand accordingly, that's very good.
I noticed a small improvement we could make to array_slice for the packed case:
We can change line 3003:
if ((Z_ARRVAL_P(input)->u.flags & HASH_FLAG_PACKED) && !preserve_keys)
=>
if ((Z_ARRVAL_P(input)->u.flags & HASH_FLAG_PACKED) && (!preserve_keys || offset ==
0))
So whenever the input array is packed, we can of course safely use a packed array for the output
array when preserve_keys is false, but also when preserve_keys is true and if (only if) the offset
is zero, because offset=0 on a packed array will yield the same result no matter whether
preserved_keys is true or false.
Ben