Re: array_values should be a no-op for packed layout arrays

From: Date: Tue, 14 Mar 2017 23:25:35 +0000
Subject: Re: array_values should be a no-op for packed layout arrays
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-98526@lists.php.net to get a copy of this message
On Wed, Mar 15, 2017 at 3:48 AM, Sara Golemon <pollita@php.net> wrote: > > Minor nit: [12=>'foo', 42=>'bar'] is not a packed array. > > [0=>'foo', 2=>'bar'] is however, so your primary point stands. > However it should be simple enough to detect when a packed array is > also vector-like (indexed from 0 to n-1) and make this minor > optimization. > > -Sara > 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)? I agree checking if the array is both packed and without gaps would still make a worthwhile optimisation.

« previous php.internals (#98526) next »