Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:38174 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 90399 invoked from network); 11 Jun 2008 23:34:38 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Jun 2008 23:34:38 -0000 Authentication-Results: pb1.pair.com header.from=michal.dziemianko@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=michal.dziemianko@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 66.249.92.172 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: michal.dziemianko@gmail.com X-Host-Fingerprint: 66.249.92.172 ug-out-1314.google.com Received: from [66.249.92.172] ([66.249.92.172:57444] helo=ug-out-1314.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A6/02-10515-D0160584 for ; Wed, 11 Jun 2008 19:34:38 -0400 Received: by ug-out-1314.google.com with SMTP id h3so232305ugf.29 for ; Wed, 11 Jun 2008 16:34:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:in-reply-to:mime-version:content-type:references; bh=QrmfbvE8/6dRIxXG37qomyk75wizBcwXT3WyM6klHQo=; b=Yf5WLUQnpezpKAkBF5B2TDAWy0GeBM4ZE+xonDbG/f4h842hl1nQafNQ+hOuMPajxE oxOdNf8q87w9l92oLR2RSz47+13IEO3V7ep7v4ot6m375w4vLKoxJ5n/RCwo/uX8NLeW 7d827dlpcaqjtdjvYlneOMvy7ODDgMC2sCP8U= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:references; b=tarEyHGUwrWbmPmMLMQXCx9qvspYzxYFHrn1JV24C1gAE/pJ8SJQcyKds9utKw7hSi bCrRitXyd6LucOaKs63rWBaFD9lsh9Vw5LBqllWHNGqY1zMZ5Oj5NyD8Q+V974sgDvJx wLF8WhtLe0m+9lL7xw9tLAaO2jEXEhN32JtNw= Received: by 10.210.89.4 with SMTP id m4mr390104ebb.120.1213227275061; Wed, 11 Jun 2008 16:34:35 -0700 (PDT) Received: by 10.210.25.6 with HTTP; Wed, 11 Jun 2008 16:34:35 -0700 (PDT) Message-ID: <31fe29920806111634l637f846es7227056264d16601@mail.gmail.com> Date: Thu, 12 Jun 2008 00:34:35 +0100 To: "Stanislav Malyshev" , internals@lists.php.net In-Reply-To: <31fe29920806111444u250d933au36d824f48c78ff5@mail.gmail.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_199_13472389.1213227275058" References: <7E62CA6E-83F4-4F9C-86FB-75EBE7D489C9@gmail.com> <484D36EB.9080202@macvicar.net> <31fe29920806110114i263a47b4sd66d4849ceb22980@mail.gmail.com> <484F910A.3080208@zend.com> <31fe29920806111444u250d933au36d824f48c78ff5@mail.gmail.com> Subject: Re: [PHP-DEV] Algorithm Optimizations - string search From: michal.dziemianko@gmail.com ("Michal Dziemianko") ------=_Part_199_13472389.1213227275058 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline I;ve just noticed that the diff I posted is form my test-bed, not the actual final version. the code should be: if (needle_len == 1){ return (char *)memchr(p, *needle, (end-p)); } instead of + if (needle_len == 1){ + return (char *)memchr(p, *needle, (end-p+1)); <- this fails for strpos("", NULL); + } + Christopher Jones wrote: * Hi Michal, * *This is always a fun topic. * *I think your stripos tests should show the no-match performance case. * *Chris I haven't said the implementation with lowering chars at the compare time is better: I've just shown some comparison results. Of course it is slower in no-match case - it is even slower when the match is closer to end of the string (it is why I posted 2 different results for the same string length - one for match in the middle, and one close to the end - which is actually similar to no-match). I just said it MIGHT be worth considering. I will analyse my logs to find out what is the average match position, to check if it is really worth implementing. ------=_Part_199_13472389.1213227275058--