Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:24897 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 59874 invoked by uid 1010); 23 Jul 2006 09:23:30 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 59858 invoked from network); 23 Jul 2006 09:23:30 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Jul 2006 09:23:30 -0000 X-PHP-List-Original-Sender: php_lists@realplain.com X-Host-Fingerprint: 209.142.136.132 msa2-mx.centurytel.net Linux 2.4/2.6 Received: from ([209.142.136.132:44635] helo=msa2-mx.centurytel.net) by pb1.pair.com (ecelerity 2.1.1.3 r(11751M)) with ESMTP id D6/37-04178-11043C44 for ; Sun, 23 Jul 2006 05:23:30 -0400 Received: from pc1 (ppp1096.lr.centurytel.net [64.91.12.199]) by msa2-mx.centurytel.net (8.13.6/8.13.6) with SMTP id k6N9NOIt021266; Sun, 23 Jul 2006 04:23:24 -0500 Message-ID: <009301c6ae39$a6514270$0201a8c0@pc1> To: , Cc: "Andrei Zmievski" References: <014e01c6acbe$680b1bc0$0201a8c0@pc1> <10845a340607210543lfe173abq2221a1c833c5d9e1@mail.gmail.com> <017701c6acc6$3a526be0$0201a8c0@pc1> <00d401c6ad61$9d235810$0201a8c0@pc1> <10845a340607221404u4f515bb9w914d4a61f9345f28@mail.gmail.com> <10845a340607221454h1c8923bcg9ca534b21853bd86@mail.gmail.com> <002901c6ae0a$70316870$0201a8c0@pc1> Date: Sun, 23 Jul 2006 04:23:24 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1807 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1807 Subject: Re: [PHP-DEV] Optimizing add_assoc_* with static keys (WAS: Re: [PHP-DEV] [PATCH] array_combine is not binary-key safe) From: php_lists@realplain.com ("Matt W") Hi Richard, Andrei, Hold on about a patch to optimize add_assoc_* and hard-coded keys. I just finished some testing to see what difference it makes: none! :-) Compilers must optimize strlen("static string") to the literal value; at least VC++ Express does. Using a dynamic string from estrdup(), *_ex with the hard-coded length was about 10% faster with a 12 character key on my old system (dual 930MHz). But again, no difference with static ones like in PHP's code. It was an optimization though in array_combine(), being dynamic key values. So, nothin' to worry about here... :-) Matt ----- Original Message ----- From: "Matt W" Sent: Saturday, July 22, 2006 > Hi Richard, > > Replacement script made it pretty simple I guess. :-) But sizeof("key")+1 > should just be sizeof("key") (which == strlen("key")+1). > > Are there any uses of add_u_assoc_* with hard-coded keys? > > These changes make things look a little messy, you think? The string is in > 2 places, etc... (Maybe why it wasn't done in the first place?) Seems like > that ZEND_STRS() macro you mentioned would work well. Or maybe cleanest > would be some new add_static_assoc_* macros (and _u versions if needed), or > some other naming convention, that uses sizeof() instead of strlen()+1. > > What do the main devs think? > > > Matt