Re: [PHP-DEV] str_replace: boyer

2001-09-09 Thread Sascha Schumann

> What is that "boyer" parameter doing there? It seems that it selects a
> different algorithm for str_replace, but what is the difference?

It is an algorithm which uses suffix-automata to speed up
locating the search pattern (Boyer-Moore algorithm).

- Sascha Experience IRCG
  http://schumann.cx/http://schumann.cx/ircg


-- 
PHP Development Mailing List 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DEV] str_replace: boyer

2001-09-09 Thread Sterling Hughes

On Sun, 9 Sep 2001, Derick Rethans wrote:

> Hello,
>
> the proto for str_replace shows this:
>
> /* {{{ proto mixed str_replace(mixed search, mixed replace, mixed subject [, bool 
>boyer])
>Replaces all occurrences of search in haystack with replace */
>
> What is that "boyer" parameter doing there? It seems that it selects a
> different algorithm for str_replace, but what is the difference?
>

m = pattern length
n = string length

Boyer-Moore is a faster algorithm, especially for larger strings
(O(m + partial) + O(mn), best performance is O(n / m)).  I see no
reason why this can't be merged as the default argument, but I'm
sure sascha had a reason.  sascha? :)

-Sterling


-- 
PHP Development Mailing List 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]