[PHP-DEV] Apply substr() optimization to array_slice()

2017-10-27 Thread Benjamin Coutu
Hello everyone, Please consider these two statements: substr($string, 0, $length); array_slice($array, 0, $length, true); Currently, with substr(), if $offset is zero and $length is smaller or equal to the original string length we just increase the reference count of the original string and r

Re: [PHP-DEV] Apply substr() optimization to array_slice()

2017-10-27 Thread Dennis Birkholz
Hello Benjamin, Am 27.10.2017 um 14:12 schrieb Benjamin Coutu: > Hello everyone, > > Please consider these two statements: > > substr($string, 0, $length); > array_slice($array, 0, $length, true); > > Currently, with substr(), if $offset is zero and $length is smaller or equal > to the origina

Re: [PHP-DEV] Apply substr() optimization to array_slice()

2017-10-27 Thread Sara Golemon
On Fri, Oct 27, 2017 at 8:12 AM, Benjamin Coutu wrote: > Now, array_slice() could be optimized similarly, but currently > (unless the resulting array is expected to be empty) we always > create a new array no matter if we actually have to. > Pushed, with an additional escape hatch for vector-like

Re: [PHP-DEV] Apply substr() optimization to array_slice()

2017-10-27 Thread Nikita Popov
On Fri, Oct 27, 2017 at 4:16 PM, Sara Golemon wrote: > On Fri, Oct 27, 2017 at 8:12 AM, Benjamin Coutu > wrote: > > Now, array_slice() could be optimized similarly, but currently > > (unless the resulting array is expected to be empty) we always > > create a new array no matter if we actually ha

Re: [PHP-DEV] Apply substr() optimization to array_slice()

2017-10-27 Thread Sara Golemon
On Fri, Oct 27, 2017 at 12:10 PM, Nikita Popov wrote: > On Fri, Oct 27, 2017 at 4:16 PM, Sara Golemon wrote: >> >> On Fri, Oct 27, 2017 at 8:12 AM, Benjamin Coutu >> wrote: >> > Now, array_slice() could be optimized similarly, but currently >> > (unless the resulting array is expected to be empt

Re: [PHP-DEV] Apply substr() optimization to array_slice()

2017-10-27 Thread Benjamin Coutu
: Nikita Popov Date: Fri, 27 Oct 2017 18:34:15 +0200 Subject: Re: [PHP-DEV] Apply substr() optimization to array_slice() > > > On Fri, Oct 27, 2017 at 12:10 PM, Nikita Popov wrote: > > On Fri, Oct 27, 2017 at 4:16 PM, Sara Golemon wrote: > >> > >> On Fri, Oct 27

Re: [PHP-DEV] Apply substr() optimization to array_slice()

2017-10-30 Thread Dmitry Stogov
-DEV] Apply substr() optimization to array_slice() On Fri, Oct 27, 2017 at 12:10 PM, Nikita Popov wrote: > On Fri, Oct 27, 2017 at 4:16 PM, Sara Golemon wrote: >> >> On Fri, Oct 27, 2017 at 8:12 AM, Benjamin Coutu >> wrote: >> > Now, array_slice() could be opti

Re: [PHP-DEV] Apply substr() optimization to array_slice()

2017-10-30 Thread Sara Golemon
On Mon, Oct 30, 2017 at 6:51 AM, Dmitry Stogov wrote: > The optimization also broke Zend/tests/bug72598.phpt and > Zend/tests/bug72598_2.phpt > Damn. I had a feeling references would rear their ugly head here. Fuggit, reverted. We can take another swing at it later, but it's not a vital optimi

Re: [PHP-DEV] Apply substr() optimization to array_slice()

2017-10-30 Thread Nikita Popov
On Mon, Oct 30, 2017 at 4:09 PM, Sara Golemon wrote: > On Mon, Oct 30, 2017 at 6:51 AM, Dmitry Stogov wrote: > > The optimization also broke Zend/tests/bug72598.phpt and > Zend/tests/bug72598_2.phpt > > > Damn. I had a feeling references would rear their ugly head here. > > Fuggit, reverted. W