On Monday, 23 May 2016 at 22:19:18 UTC, Andrei Alexandrescu wrote:
On 05/23/2016 03:11 PM, qznc wrote:
Actually, std find should be faster, since it could use the
Boyer Moore
algorithm instead of naive string matching.
Conventional wisdom has it that find() is brute force and
that's that, but probably it's time to destroy. Selectively
using advanced searching algorithms for the appropriate inputs
is very DbI-ish.
Since I work a lot with text, I use canFind etc. a lot. It'd be
nice to be able to choose faster algorithms. People are often
advised to use library functions instead of rolling their own,
because library functions are optimized for speed, but this
doesn't seem to be true of Phobos. Simple everyday tasks like
string matching should be as fast as C.
There are a few nice precedents of blend algorithms, see e.g.
http://effbot.org/zone/stringlib.htm.
Writing a generic subsequence search blend algorithm, one that
chooses the right algorithm based on a combination of static
and dynamic decisions, is quite a fun and challenging project.
Who wanna?
Andrei