Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:26959 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 17339 invoked by uid 1010); 14 Dec 2006 17:22:35 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 17324 invoked from network); 14 Dec 2006 17:22:34 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Dec 2006 17:22:34 -0000 Authentication-Results: pb1.pair.com smtp.mail=nlopess@php.net; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=nlopess@php.net; sender-id=unknown Received-SPF: error (pb1.pair.com: domain php.net from 212.55.154.25 cause and error) X-PHP-List-Original-Sender: nlopess@php.net X-Host-Fingerprint: 212.55.154.25 relay5.ptmail.sapo.pt Linux 2.4/2.6 Received: from [212.55.154.25] ([212.55.154.25:51164] helo=sapo.pt) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id EB/20-04864-73881854 for ; Thu, 14 Dec 2006 12:22:34 -0500 Received: (qmail 15969 invoked from network); 14 Dec 2006 17:21:56 -0000 Received: from unknown (HELO sapo.pt) (10.134.35.210) by relay6 with SMTP; 14 Dec 2006 17:21:56 -0000 Received: (qmail 27381 invoked from network); 14 Dec 2006 17:21:55 -0000 X-AntiVirus: PTMail-AV 0.3-0.88.6 X-Virus-Status: Clean (0.03234 seconds) Received: from unknown (HELO pc07653) (nunoplopes@sapo.pt@[82.155.78.163]) (envelope-sender ) by mta15 (qmail-ldap-1.03) with SMTP for ; 14 Dec 2006 17:21:55 -0000 Message-ID: <00e501c71fa4$5bdee3a0$0100a8c0@pc07653> To: "Ron Korving" Cc: "PHPdev" References: <10.23.32177.CA640854@pb1.pair.com> Date: Thu, 14 Dec 2006 17:21:56 -0000 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.3028 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3028 Subject: Re: [PHP-DEV] [PATCH] 1 small optimization and 1 cleanup From: nlopess@php.net ("Nuno Lopes") > Hi, > > Below are 2 patches for the latest 5.2. The first patch rewrites > pcre_get_compiled_regex_ex() in ext/pcre/php_pcre.c from line 417, saving > up > to 3 comparison statements (?:). The second patch removes a pointless > statement (setting a local variable right before a return statement) from > json_determine_array_type() in ext/json/json.c on line 92. well about the pcre one I could argument that your patch makes the code bigger and potentially slower :P (due to cache misses) Anyway, I do trust the compiler to do such kind of trivial optimizations.. > Index: ext/pcre/php_pcre.c > =================================================================== > RCS file: /repository/php-src/ext/pcre/php_pcre.c,v > retrieving revision 1.209 > diff -u -r1.209 php_pcre.c > --- ext/pcre/php_pcre.c 10 Oct 2006 12:43:34 -0000 1.209 > +++ ext/pcre/php_pcre.c 13 Dec 2006 18:22:07 -0000 > @@ -417,18 +417,21 @@ > PHPAPI pcre* pcre_get_compiled_regex_ex(char *regex, pcre_extra **extra, > int *preg_options, int *compile_options TSRMLS_DC) > { > pcre_cache_entry * pce = pcre_get_compiled_regex_cache(regex, > strlen(regex) TSRMLS_CC); > - > - if (extra) { > - *extra = pce ? pce->extra : NULL; > - } > - if (preg_options) { > - *preg_options = pce ? pce->preg_options : 0; > + > + if (pce) > + { > + if (extra) *extra = pce->extra; > + if (preg_options) *preg_options = pce->preg_options; > + if (compile_options) *compile_options = pce->compile_options; > + return pce->re; > } > - if (compile_options) { > - *compile_options = pce ? pce->compile_options : 0; > + else > + { > + if (extra) *extra = NULL; > + if (preg_options) *preg_options = 0; > + if (compile_options) *compile_options = 0; > + return NULL; > } > - > - return pce ? pce->re : NULL; > } > /* }}} */