Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:66575 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 95575 invoked from network); 11 Mar 2013 06:35:10 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Mar 2013 06:35:10 -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.219.46 as permitted sender) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 209.85.219.46 mail-oa0-f46.google.com Received: from [209.85.219.46] ([209.85.219.46:47551] helo=mail-oa0-f46.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D9/33-09030-C1B7D315 for ; Mon, 11 Mar 2013 01:35:09 -0500 Received: by mail-oa0-f46.google.com with SMTP id k1so4152112oag.33 for ; Sun, 10 Mar 2013 23:35:04 -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=VwUER/IEcoLKZ5/9XsCiYsrGKKtnwBZQkEpfGeqZaBg=; b=eQuV3cunWakvLBPGExo+4WVvEmfo8CKozmsINHopSYH+/nWdYx46j0whqTaHT7Nc/D tnorrHbgeEdgNRWxTgMKCV6wr7JhCFKd1dVoDE2pVGw7QsYGsaoR6ZnOlKBli04HHpjR Wwcsgcl2TITQBphsvdI0NssoDFGqWRa4Ms6YijCADplc1NdlrnZJ7wGBpSn0+ql7bHgH EI+YVkBRvrPpJaNJN7TZ+CGbM+h73ZTAqREeN6tNO65vhgQkCk1ePJQPG3sWa+pMLJhG dgDPgzUh8HH6/mb2AggUbkBuIueLJzhnvw8otkQXGSzFMW0gNDtohpRscH0cXOJDoK0c pQiw== MIME-Version: 1.0 X-Received: by 10.182.156.103 with SMTP id wd7mr7562798obb.33.1362983704767; Sun, 10 Mar 2013 23:35:04 -0700 (PDT) Received: by 10.182.242.79 with HTTP; Sun, 10 Mar 2013 23:35:04 -0700 (PDT) In-Reply-To: References: Date: Mon, 11 Mar 2013 10:35:04 +0400 Message-ID: To: Nikita Popov Cc: PHP internals , Zeev Suraski , Andi Gutmans Content-Type: multipart/alternative; boundary=f46d0444e8358f150004d7a05f71 X-Gm-Message-State: ALoCoQmyTthsiSJea8RoPRm5JjIrypHccrS6deIQ0eSV3hVbgzgUSu+tkOXvJkNBonnikJ3B1ZITrnCDwFm0flprEvQ3Y1gdOjsZbx1/EHLTNUCTARJjsfMOH3artltzQjW/hs7ZuKP/ Subject: Re: [PHP-DEV] Re: [VOTE] Allow non-scalar keys in foreach From: dmitry@zend.com (Dmitry Stogov) --f46d0444e8358f150004d7a05f71 Content-Type: text/plain; charset=UTF-8 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 > --f46d0444e8358f150004d7a05f71--