Re: Algorithm Optimizations - string search

From: Date: Wed, 11 Jun 2008 23:34:35 +0000
Subject: Re: Algorithm Optimizations - string search
References: 1 2 3 4 5 6  Groups: php.internals 
Request: Send a blank email to internals+get-38174@lists.php.net to get a copy of this message
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.

« previous php.internals (#38174) next »