Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:66497 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 16311 invoked from network); 6 Mar 2013 17:16:31 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Mar 2013 17:16:31 -0000 Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.219.50 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.219.50 mail-oa0-f50.google.com Received: from [209.85.219.50] ([209.85.219.50:37302] helo=mail-oa0-f50.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E1/77-03015-EE977315 for ; Wed, 06 Mar 2013 12:16:31 -0500 Received: by mail-oa0-f50.google.com with SMTP id l20so12707733oag.23 for ; Wed, 06 Mar 2013 09:16:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=fE2Y+xNvfKczm5BF+Fvpsn9nPRqUZ5fo4c7jRQ7qISI=; b=rr2WwaoOLU1bk0G3oVnu4wt5VTmQr4uBbj69RUM4Qp1w7jb7Av5P+ZW9VerDaPWxUN JHhc1MWBms4bs1FaW3WsBZ7tplaXQuULhc/4EsDLiW5UTQ3jLGWU2qONQrpu4e3mKimu efOj+QoaAhoSPKZ7X4Ar6Cehl7DUGqsPizPfXTr8IuBp4Q05zhVF+CG/4vv9zdGawolL A/pz7RXPJaqJpW+opvFS584Cu7vssEx1NtohWMaQ5gwNI/CEZ7uf0XoS+Dvl5Qek5PpJ BziCeBQy1ldWfdmdc+j4DOAi6053uvaF0nKPjdCGrmNqn4Z1wrQIGEeh3ODNI4xG3KwE ZjMw== MIME-Version: 1.0 X-Received: by 10.60.11.228 with SMTP id t4mr12560114oeb.42.1362590188127; Wed, 06 Mar 2013 09:16:28 -0800 (PST) Received: by 10.182.49.136 with HTTP; Wed, 6 Mar 2013 09:16:27 -0800 (PST) In-Reply-To: References: Date: Wed, 6 Mar 2013 18:16:27 +0100 Message-ID: To: Dmitry Stogov Cc: PHP internals , Zeev Suraski , Andi Gutmans Content-Type: multipart/alternative; boundary=e89a8fb1ed06234ecb04d744c00d Subject: Re: [PHP-DEV] Re: [VOTE] Allow non-scalar keys in foreach From: nikita.ppv@gmail.com (Nikita Popov) --e89a8fb1ed06234ecb04d744c00d Content-Type: text/plain; charset=ISO-8859-1 On Wed, Mar 6, 2013 at 5:41 PM, Dmitry Stogov wrote: > Hi Nikita, > > few notes about the patch... > > - you may avoid estrndup() in zend_hash_current_key_zval_ex() for interned > strings. > Good idea, I'll do that. > > - I didn't completely get why did you change the "key" operand type from > IS_TMP_VAR to IS_VAR and how it affects performance > As I understood now you need to allocate new zval on each loop iteration > even for foreach over plain arrays. :( > Good point, I didn't consider the performance implication the type change would have. The intent behind that was to avoid copying the get_current_key zval into the temporary (and destroying it then), but I didn't consider how it affects normal arrays. This should be changed back to TMP_VAR. 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? Nikita --e89a8fb1ed06234ecb04d744c00d--