D-Programming-Language/phobos — pull request #1492 by monarchdodra (2013-08-18 10:33:39+00:00)
Title: fix Issue 10403 - memchr optimization for std.algorithm.find

This improves the implementation of `find!(R, E)` as well as `find!(pred, R)`.

* strings:

Improvements to UTF8 and UTF16 are particularly spectacular, with performance improvements up to ×20 for normal strings (read `"hello world"`).

These performance improvements to string test that the needle fit inside a single code unit. However, even if it doesn't, I still get a rough 100% performance improvement in the general case, with or without default pred.

* `[u]byte[]`

Implemented 10403: Same as with strings, the performance improvement is spectacular when it triggers.

* Standard arrays:

I added a path for raw arrays, which uses a foreach rather than a loop. It makes little difference for `dmd -inline`, but I get a bit more than 100% performance improvement for non `-inline`, so worth it. (also, stangelly enough, `gdc -inline` gets a big benefit. Don't know why...)