D-Programming-Language/phobos — pull request #1553 by blackwhale (2013-09-06 22:07:49+00:00)
Title: Some simple std.regex optimization

This picks a couple of low-hanging fruits to optimize R-T & (a bit) C-T regex.

First is inlining. DMD basically *never inlines stuff that is in the library and is not a template*. It doesn't matter if it has the source for it (obviously DMD has all of phobos source).
Currently the only way out is marking everything as empty-arg template and this gets us the rough analog of 'explicitly inlined' in C++.

Anyhow - around 30% of speed gain is obtained by adding a couple of empty brackets here and there alone. Or rather I got them back (in the days of FReD it was always inlined).

Second is removal of indirect call in the outer loop search loop. Basically it had to pick if it can do fast (kicked) search or if it should just use char by char crawling. Being outer loop I thought it wouldn't cost much to use an indirect call. Yet test runs on line by line matching indicate a noticeble speed up of around ~2% in the new version.

P.S. See e.g. this sample (one of examples that are currently difficult for std.regex) https://gist.github.com/blackwhale/6470498