Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:66499 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 21058 invoked from network); 6 Mar 2013 18:14:14 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Mar 2013 18:14:14 -0000 Authentication-Results: pb1.pair.com header.from=reeze.xia@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=reeze.xia@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.160.51 as permitted sender) X-PHP-List-Original-Sender: reeze.xia@gmail.com X-Host-Fingerprint: 209.85.160.51 mail-pb0-f51.google.com Received: from [209.85.160.51] ([209.85.160.51:33915] helo=mail-pb0-f51.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 70/58-03015-57787315 for ; Wed, 06 Mar 2013 13:14:13 -0500 Received: by mail-pb0-f51.google.com with SMTP id un15so6303173pbc.24 for ; Wed, 06 Mar 2013 10:14:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:date:from:to:cc:message-id:in-reply-to:references :subject:x-mailer:mime-version:content-type; bh=/FNrtWRK733BHHsR6x+nrsSt5LiJkkQnKDui9dZ3/c4=; b=S/bpHEconMhi8/udz/R/WQXG4VxjZRplHPnMAh/zBmZFD69OiZOiK1YQyl+wCF6S27 HL3fo/J3mZEDnR/Xag8X4VBb4mJ1tRHZlsPIy4k71paT0Vg4AjU9tkD6W6txSNKTnmJY KT1Y5utJufkryFuJzdJwd5z0qumZXTBNobZ8HB83NBVMSsHBLUQEdwZa4fv6pyH+XDdR Fnhclb//DwVWS+6ztIkveI37DjUlUm4y9VLP01o+pnvH7MizzIac2APfREvS33Dhbj+A nx6dyMkf07IpqcjvjJPtUhpdHNTZOPimsbjjqDxkaqz6Cb84126a0bfNezqhPiJPyjlX 3Cbw== X-Received: by 10.68.138.170 with SMTP id qr10mr48172484pbb.190.1362593649709; Wed, 06 Mar 2013 10:14:09 -0800 (PST) Received: from [192.168.0.102] ([221.179.168.26]) by mx.google.com with ESMTPS id rr14sm32293329pbb.34.2013.03.06.10.14.05 (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 06 Mar 2013 10:14:08 -0800 (PST) Sender: reeze Date: Thu, 7 Mar 2013 02:14:06 +0800 To: Dmitry Stogov Cc: Nikita Popov , PHP internals , Zeev Suraski , Andi Gutmans Message-ID: <386313C37F2248FC953992FE658FAC5F@gmail.com> In-Reply-To: References: X-Mailer: sparrow 1.6.4 (build 1176) MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="5137876e_643c9869_5d0c" Subject: =?utf-8?Q?=E5=9B=9E=E5=A4=8D=EF=BC=9A_?=[PHP-DEV] Re: [VOTE] Allow non-scalar keys in foreach From: reeze@php.net (Reeze Xia) --5137876e_643c9869_5d0c Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi Nikita, I got some test failure with the patch, one test failure and some mem= ory leaks. see: https://gist.github.com/reeze/5101596 -- =20 reeze =7C reeze.cn =E5=B7=B2=E4=BD=BF=E7=94=A8 Sparrow (http://www.sparrowmailapp.com/=3Fsig= ) =20 =E5=9C=A8 2013=E5=B9=B43=E6=9C=887=E6=97=A5=E6=98=9F=E6=9C=9F=E5=9B=9B=EF= =BC=8C=E4=B8=8A=E5=8D=881:28=EF=BC=8CDmitry Stogov =E5=86=99=E9=81=93=EF=BC= =9A > On Wed, Mar 6, 2013 at 9:16 PM, Nikita Popov wrote: > =20 > > On Wed, Mar 6, 2013 at 5:41 PM, Dmitry Stogov wrote: > > =20 > > > Hi Nikita, > > > =20 > > > few notes about the patch... > > > =20 > > > - you may avoid estrndup() in zend=5Fhash=5Fcurrent=5Fkey=5Fzval=5F= ex() for > > > interned strings. > > > =20 > > =20 > > =20 > > Good idea, I'll do that. > > =20 > > > =20 > > > - I didn't completely get why did you change the =22key=22 operand = type from > > > IS=5FTMP=5FVAR to IS=5FVAR and how it affects performance > > > As I understood now you need to allocate new zval on each loop iter= ation > > > even for foreach over plain arrays. :( > > > =20 > > =20 > > =20 > > Good point, I didn't consider the performance implication the type ch= ange > > would have. The intent behind that was to avoid copying the get=5Fcur= rent=5Fkey > > zval into the temporary (and destroying it then), but I didn't consid= er how > > it affects normal arrays. This should be changed back to TMP=5FVAR. > > =20 > =20 > =20 > It would be great. I can agree that new features may work slower, but > really don't like when they slowdown existing and mach more usual cases= . > =20 > =20 > > =20 > > I wonder what would be a good way to avoid allocating a temporary zva= l for > > the key and freeing it again. Do you think it would be okay to pass > > &EX=5FT((opline+1)->result.var).tmp=5Fvar into ->get=5Fcurrent=5Fkey(= ) so the value > > can be written directly into it without doing extra allocs/frees=3F > > =20 > =20 > I'm not sure it'll work. TMP=5FVARs 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= =5FVAR > and call copy=5Fctor(). > =20 > Please, let me review the patch when it's ready (I won't be available o= n > March 8 and weekend). > =20 > Thanks. Dmitry. =20 --5137876e_643c9869_5d0c--