On Thu, Sep 3, 2020, 7:05 PM Sara Golemon <poll...@php.net> wrote:

> On Thu, Sep 3, 2020 at 10:35 AM David Rodrigues <david.pro...@gmail.com>
> wrote:
>
> > Do you think that it could be proxied? I mean, optimize foreach
> > (array_keys()...) syntax to not call array_keys() in fact, but a
> optimized
> > version of foreach to handle key only. I don't know it opcache could do
> > that, and if it already does.
> >
> >
> I wouldn't use the word "proxied", but yes. In my mind the compiler would
> see:
>
> foreach(\array_keys($arr) as $key) {
>
> and quietly transform that into:
>
> foreach ($arr as $key => $_unusedVariableNameThatIsntEvenSpilledToTheScope)
> {
>
> Thus not iterating the array twice and creating a temporary array of key
> names.
>

Good idea; since I'm kind of bored, I'll try to implement a prototype
myself during my free time.

-Sara
>

Reply via email to