Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:24912 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 15245 invoked by uid 1010); 23 Jul 2006 17:29:36 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 15230 invoked from network); 23 Jul 2006 17:29:36 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Jul 2006 17:29:36 -0000 Authentication-Results: pb1.pair.com header.from=iliaal@gmail.com; domainkeys=good DomainKey-Status: good X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: iliaal@gmail.com X-Host-Fingerprint: 64.233.184.228 wr-out-0506.google.com Linux 2.4/2.6 Received: from ([64.233.184.228:63012] helo=wr-out-0506.google.com) by pb1.pair.com (ecelerity 2.1.1.3 r(11751M)) with ESMTP id 5A/14-04178-CF1B3C44 for ; Sun, 23 Jul 2006 13:29:33 -0400 Received: by wr-out-0506.google.com with SMTP id 70so534400wra for ; Sun, 23 Jul 2006 10:29:30 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:in-reply-to:references:mime-version:x-priority:content-type:message-id:cc:from:subject:date:to:x-mailer:sender; b=sQujJdn80MQ2Y68BoD6nBgtWOgBrQ6FklycpkJySh+2cYYhe1Xi4aOTYvrI6PXp+W2XEzCY6ZjQEomU4URGKDeefTqeA2f3Gt2PgOzb5Rv+joWqKGHJpGz+w+mty9tFfVRp7iFs5oR50Rd3oKNJXPHuEB6MPAFQIDniXjUqsVQc= Received: by 10.64.21.6 with SMTP id 6mr2478448qbu; Sun, 23 Jul 2006 10:29:30 -0700 (PDT) Received: from ?192.168.1.6? ( [72.59.8.142]) by mx.gmail.com with ESMTP id d2sm2261298qbc.2006.07.23.10.29.29; Sun, 23 Jul 2006 10:29:29 -0700 (PDT) In-Reply-To: <017701c6acc6$3a526be0$0201a8c0@pc1> References: <014e01c6acbe$680b1bc0$0201a8c0@pc1> <10845a340607210543lfe173abq2221a1c833c5d9e1@mail.gmail.com> <017701c6acc6$3a526be0$0201a8c0@pc1> Mime-Version: 1.0 (Apple Message framework v752.2) X-Priority: 3 Content-Type: multipart/alternative; boundary=Apple-Mail-2--725091793 Message-ID: <8EABC9D5-143B-4FA9-9CB0-14375E6B8193@prohost.org> Cc: , Date: Sun, 23 Jul 2006 13:29:27 -0400 To: Matt W X-Mailer: Apple Mail (2.752.2) Sender: Ilia Alshanetsky Subject: Re: [PHP-DEV] [PATCH] array_combine is not binary-key safe From: ilia@prohost.org (Ilia Alshanetsky) --Apple-Mail-2--725091793 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Most compiler (I know gcc and Visual C do) will optimize strlen ("static_string"). On 21-Jul-06, at 9:04 AM, Matt W wrote: > Hi Richard, > > I think I've seen those instances that you're referring to. By > fixed length > string I assume you mean hard-coded "string_key". Yeah, I would > think those > should use add_assoc_*_ex() since the length is known (sizeof > ("string_key") > etc.) to save unnecessary strlen() calls. > > Unless compilers optimize the strlen("string_key") + 1 to a > constant from > the add_assoc_*() macro. But I wouldn't think that's the case...? :-/ > > > Matt > > > ----- Original Message ----- > From: "Richard Quadling" > Sent: Friday, July 21, 2006 > >> Hi, >> >> There are 46 uses of add_assoc_zval() in the CVS. Many are with >> fixed >> length strings for the key. Should the others all be using >> add_assoc_zval_ex() ? >> >> On 21/07/06, Matt W wrote: >>> Hi, >>> >>> I don't know if array_combine() was intentionally made binary-key > unsafe, >>> but it seems wrong and inconsistent since binary keys work >>> everywhere > else I >>> can think of -- including array_flip() and the new array_fill_keys >>> (). > And >>> updating it is a bit of an optimization by eliminating strlen() >>> calls. > :-) >>> >>> I also changed the error message to be more grammatically-correct >>> and > fixed >>> some typos in the description. >>> >>> http://www.realplain.com/php/array_combine_binkey.diff >>> http://www.realplain.com/php/array_combine_binkey_5_2.diff >>> >>> >>> Thanks, >>> Matt > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > Ilia Alshanetsky --Apple-Mail-2--725091793--