Re: [PHP-DEV] Optimizing array_reverse for packed hash tables (when preserve_keys=false)

2016-07-28 Thread Benjamin Coutu
Hi Xinchen, The code I used was simply derived from the code of the array_slice implementation (totally analogous). Maybe your suggested changes (check HASH_FLAG_PACKED fist + Z_TRY_ADDREF) should be carried over to array_slice then as well. Please go ahead and commit a patch, I'd prefer to sti

Re: [PHP-DEV] Optimizing array_reverse for packed hash tables (when preserve_keys=false)

2016-07-27 Thread Xinchen Hui
Hey: On Wed, Jul 27, 2016 at 10:42 PM, Benjamin Coutu wrote: > Hello Xinchen, > > Analogue to the array_slice implementation, the array_reverse function > could also be optimized for packed hash tables when preserve_keys is false > (most common). > The following patch should do just that: > > if

[PHP-DEV] Optimizing array_reverse for packed hash tables (when preserve_keys=false)

2016-07-27 Thread Benjamin Coutu
Hello Xinchen, Analogue to the array_slice implementation, the array_reverse function could also be optimized for packed hash tables when preserve_keys is false (most common). The following patch should do just that: if (!preserve_keys && (Z_ARRVAL_P(input)->u.flags & HASH_FLAG_PACKED)) {