Why do the same work about 'IndexOfAny' and 'indexOf' function?

Robert burner Schadek via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Jan 9 05:54:00 PST 2015


On Friday, 9 January 2015 at 13:25:17 UTC, ketmar via 
Digitalmars-d-learn wrote:
> if you *really* concerned with speed here, you'd better 
> consider using
> regular expressions. as regular expression can be precompiled 
> and then
> search for multiple words with only one pass over the source 
> string. i
> believe that std.regex will use variation of Thomson algorithm 
> for
> regular expressions when it is able to do so.

IMO that is not sound advice. Creating the state machine and 
running will be more costly than using canFind or indexOf how 
basically only compare char by char.

If speed is really need use strstr and look if it uses sse to 
compare multiple chars at a time. Anyway benchmark and then 
benchmark some more.


More information about the Digitalmars-d-learn mailing list