Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:38118 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 46084 invoked from network); 9 Jun 2008 13:49:40 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 Jun 2008 13:49:40 -0000 Authentication-Results: pb1.pair.com header.from=nlopess@php.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=nlopess@php.net; spf=unknown; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 212.55.154.26 as permitted sender) X-PHP-List-Original-Sender: nlopess@php.net X-Host-Fingerprint: 212.55.154.26 relay6.ptmail.sapo.pt Linux 2.4/2.6 Received: from [212.55.154.26] ([212.55.154.26:59664] helo=sapo.pt) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7E/8B-21959-2F43D484 for ; Mon, 09 Jun 2008 09:49:40 -0400 Received: (qmail 5102 invoked from network); 9 Jun 2008 13:49:35 -0000 Received: from unknown (HELO sapo.pt) (10.134.37.165) by relay6 with SMTP; 9 Jun 2008 13:49:35 -0000 Received: (qmail 9344 invoked from network); 9 Jun 2008 13:49:35 -0000 X-AntiVirus: PTMail-AV 0.3-0.92.0 X-Virus-Status: Clean (0.01445 seconds) Received: from unknown (HELO pc07654) (nunoplopes@sapo.pt@[85.240.52.67]) (envelope-sender ) by mta15 (qmail-ldap-1.03) with SMTP for ; 9 Jun 2008 13:49:35 -0000 Message-ID: To: , "Michal Dziemianko" References: <7E62CA6E-83F4-4F9C-86FB-75EBE7D489C9@gmail.com> In-Reply-To: <7E62CA6E-83F4-4F9C-86FB-75EBE7D489C9@gmail.com> Date: Mon, 9 Jun 2008 14:49:16 +0100 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 Windows Mail 6.0.6001.18000 X-MimeOLE: Produced By Microsoft MimeOLE V6.0.6001.18000 Subject: Re: [PHP-DEV] Algorithm Optimizations - string search From: nlopess@php.net ("Nuno Lopes") Hi, So some comments: - you have some problems with the indentation. We only use tabs, so please stick to that. Also, there are some lines that are not indented correctly - Have you considered the Boyer-Moore algorithm? I think it's a little faster than KMP (take a look at e.g. http://www.cs.utexas.edu/users/moore/best-ideas/string-searching/) - please remove the //TUTAJ SKONCZYLEM comment - revert this change (as well as a few other that are similar): - for (r_end = r + Z_STRLEN_P(return_value) - 1; r < r_end; ) { + for ( r_end = r + Z_STRLEN_P( return_value ) - 1; r < r_end; ){ (we like small diffs, not long diffs with changes that also break our coding standards. e.g. we don't use space after the '(' char. Philip wrote a nice article about diffs at http://wiki.php.net/doc/articles/whitespace) - in strrpos_reverse_kmp() I think you allocate 4 bytes less that you want - I think you've too many comments.. We don't need 1 comment per line :) After fixing all these points and after running the test suite (with valgrind) and make sure there are no regressions, I think it's safe for you to commit. Still, I would like to see some performance figures comparing the KMP and the Boyer-Moore (or point me some papers about the subject). Thanks for your work and good luck for the rest of the SoC project :) Nuno ----- Original Message ----- From: "Michal Dziemianko" To: Sent: Monday, June 09, 2008 12:39 PM Subject: [PHP-DEV] Algorithm Optimizations - string search > Hello, > Here: http://212.85.117.53/DIFF.txt is small patch that will speed > up following functions: > strpos, > stripos, > strrpos > strripos, > and probably some others (all that use zend_memnstr/php_memnstr > function) > > The speedup of zend_memnstr is about 8% on average (about 30% in case > of artificial strings). > Functions strrpos and strripos are about 25% faster on average. > > The only drawback - it needs some additional space (size of the needle). > > All functions pass all the tests. > > If it looks fine than I will apply for cvs account. > > Cheers, > Michal