Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:66577 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 7516 invoked from network); 11 Mar 2013 08:50:17 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Mar 2013 08:50:17 -0000 Authentication-Results: pb1.pair.com header.from=dmitry@zend.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=dmitry@zend.com; spf=unknown; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain zend.com does not designate 209.85.214.169 as permitted sender) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 209.85.214.169 mail-ob0-f169.google.com Received: from [209.85.214.169] ([209.85.214.169:35555] helo=mail-ob0-f169.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id DC/E4-09030-8CA9D315 for ; Mon, 11 Mar 2013 03:50:17 -0500 Received: by mail-ob0-f169.google.com with SMTP id ta14so3111084obb.0 for ; Mon, 11 Mar 2013 01:50:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type:x-gm-message-state; bh=rEZVGNR3vafjGDdffBQ0TjiQoheUJugN3pKk3UwoIz0=; b=WtWNTXqXPFXmyGx5e0U1Pbv6eLULMrbGepHhNEQ1ccUjEGzMC9vBzffGeQ1zePokh6 YWUvXy/Tt+hgQCKlmcZQD5EkCPdD+ipSUEdW9juZRP26kAmdhzCW/2Ecvcm2c1D4sd31 +g5itQ8dDnNCYM+WC/JT535C78u5ivI8voukJWPXBsZsY20VO7ql9Z1eohytChv6AbeP 3tPrqgUI0cytBFiIp85fOU9lxkGPetox5m7MclrIti1v2eMOlsesBo9pMo+yLTuS8qwp 3E88VnlRRkeNTkusyf21OtjZXWXsWng89sQryUkI11fkhZbPGNYwOFCEsXs9lVDjNLu7 94Cw== MIME-Version: 1.0 X-Received: by 10.60.18.136 with SMTP id w8mr7988970oed.84.1362991814052; Mon, 11 Mar 2013 01:50:14 -0700 (PDT) Received: by 10.182.242.79 with HTTP; Mon, 11 Mar 2013 01:50:13 -0700 (PDT) In-Reply-To: References: Date: Mon, 11 Mar 2013 12:50:13 +0400 Message-ID: To: Nikita Popov Cc: PHP internals , Zeev Suraski , Andi Gutmans Content-Type: multipart/alternative; boundary=e89a8fb1f04ce8f8e404d7a242ce X-Gm-Message-State: ALoCoQn5twUoEYhfHI1WSLD4Jn9LOPKlroK26CwBVGaHe1vTM5gxL+OE25S0hPwQjFHYG7DfE6ffZyJqSFUrsrDKU3zDNbYrEA/LFf7zp/vTuNqmo3BXoWnaHVT4z9+kaiUzcrrLcWGQ Subject: Re: [PHP-DEV] Re: [VOTE] Allow non-scalar keys in foreach From: dmitry@zend.com (Dmitry Stogov) --e89a8fb1f04ce8f8e404d7a242ce Content-Type: text/plain; charset=UTF-8 Hi Nikita, The patch looks good. I have just few comments - In ZEND_FE_FETCH handler PLAIN_OBJECT may have only STRING keys. I didn't get why you added unreachable code for INT and NULL. - At first, I fought, that it might be a good idea to change zend_user_it_get_current_key() to return SUCCESS/FAILURE instead of returning IS_NULL that has a special meaning. But after looking into the FE_FETCH code before the commit I understood where this NULL came from. I know that NULL key may not appear for plain array and objects but I'm not sure about iterators and generators. Now IS_NULL keys may mean that iterator returned it directly IS_NULL or may be it was returned because of some error conditions. Probably it's not a problem. What do you think? I personally, irrelevant to this patch. I didn't found serious technical issues, so I think it may be accepted. Thanks. Dmitry. On Mon, Mar 11, 2013 at 10:35 AM, Dmitry Stogov wrote: > Hi Nikita, > > Thanks. I'll review it today. > > Dmitry. > > > On Sun, Mar 10, 2013 at 1:47 AM, Nikita Popov wrote: > >> On Wed, Mar 6, 2013 at 6:28 PM, Dmitry Stogov wrote: >> >>> >>>> I wonder what would be a good way to avoid allocating a temporary zval >>>> for the key and freeing it again. Do you think it would be okay to pass >>>> &EX_T((opline+1)->result.var).tmp_var into ->get_current_key() so the value >>>> can be written directly into it without doing extra allocs/frees? >>>> >>>> >>> I'm not sure it'll work. TMP_VARs don't initialize refcount, they can't >>> be referenced or marked as a possible root of garbage. >>> I took only a very quick look over the patch and didn't understand all >>> the details, but probably it must be possible to copy iterator key into >>> TMP_VAR >>> and call copy_ctor(). >>> >>> Please, let me review the patch when it's ready (I won't be available on >>> March 8 and weekend). >>> >>> Thanks. Dmitry. >>> >> >> Here is the new patch: >> https://github.com/nikic/php-src/commit/a1bfc8105713eeb4e66e852b81884b567ad56020 >> It passes in the tmp_var in as a zval*, which can then be set using the >> ZVAL_* macros (basically the same way as it's done with return_value). This >> way we don't need any further zval allocs and frees. It also turned out >> that doing it this way is more convenient to use in the respective key >> handlers. >> >> Nikita >> > > --e89a8fb1f04ce8f8e404d7a242ce--