On Fri, 09 Jan 2015 13:54:00 +0000 Robert burner Schadek via Digitalmars-d-learn <digitalmars-d-learn@puremagic.com> wrote:
> 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. std.regex can use CTFE to compile regular expressions (yet it sometimes slower than non-CTFE variant), and i mean that we compile regexp before doing alot of searches, not before each single search. if you have alot of words to match or alot of strings to check, regexp can give a huge boost. sure, it all depends of code patterns.
signature.asc
Description: PGP signature