Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:111829 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 28103 invoked from network); 3 Sep 2020 16:59:53 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 3 Sep 2020 16:59:53 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 09B25180561 for ; Thu, 3 Sep 2020 09:05:05 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: * X-Spam-Status: No, score=1.4 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-lj1-f182.google.com (mail-lj1-f182.google.com [209.85.208.182]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 3 Sep 2020 09:05:04 -0700 (PDT) Received: by mail-lj1-f182.google.com with SMTP id r13so4428308ljm.0 for ; Thu, 03 Sep 2020 09:05:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=iXw2XDJN2lb9LEsxBLhZ6tVEShVvXhPnxTE6JBknxU0=; b=l3kgwhpgE8vCKmJ1PJQQCFrklvzsSZIzF1ykIljaz3tNV7VmqNsFXV1q5P4S9z25/8 A87zEQYbAWLJDaJXJ6NaAFRliP9ZLUZhQo7ThBpw0nSmLCjWtny5JNo+IyzowrBTUaf3 dkg8II3KOcB4ZIw0J/DFY0dFgmyyE09MZQ8V/FxK8KChLH5tZx4Vjc5bm0Qadb0Q6V7v dZ4jAwUPuWpv5mAd1FKk4Ai84iFw5ncJyzvNuxNgrsuSS9HuoEGRiy+fS+pQP4ofny/4 wUkdNeg2tS4fDfXzSbY/0I1bxHsB4WZiN/18gPGtZqzpSRgj/TUlHnaFbdBhXR9ghCZi B1mA== X-Gm-Message-State: AOAM530eSUpvL9IHfoMOvxcyywLUK3fka1semYCY/ZKhMEa1G+8rNlUk oNEOMAlXU5+vlAlxDMKEuzo5+bWSFeYqxFtvu+pOAQ== X-Google-Smtp-Source: ABdhPJzWJK41c4YixUVTpGHR19gjrJYbkOp3caRXj5ZWt4Wb22EF1+Ti8NjE1C+aWtIodQ8XZjRyebVvtFtIds0BIjw= X-Received: by 2002:a2e:7408:: with SMTP id p8mr1516521ljc.451.1599149102550; Thu, 03 Sep 2020 09:05:02 -0700 (PDT) MIME-Version: 1.0 References: <89FF9360-609A-439F-BDBE-B3B4C141E00F@newclarity.net> <20200903095840.4b83640d@mcmic-probook.opensides.be> In-Reply-To: Date: Thu, 3 Sep 2020 11:04:51 -0500 Message-ID: To: David Rodrigues Cc: PHP internals Content-Type: multipart/alternative; boundary="00000000000033689505ae6aea60" Subject: Re: [PHP-DEV] Draft RFC: foreach iteration of keys without values From: pollita@php.net (Sara Golemon) --00000000000033689505ae6aea60 Content-Type: text/plain; charset="UTF-8" On Thu, Sep 3, 2020 at 10:35 AM David Rodrigues 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. -Sara --00000000000033689505ae6aea60--