faster splitter

Seb via Digitalmars-d digitalmars-d at puremagic.com
Wed Jun 1 05:41:19 PDT 2016


On Wednesday, 1 June 2016 at 12:14:07 UTC, Patrick Schluter wrote:
> On Tuesday, 31 May 2016 at 17:54:34 UTC, qznc wrote:
>> There is a special version of find for searching a single char 
>> in a string. Using a one-letter needle string is more like a 
>> user mistake than something to optimize for.
>
> At compile time you may not know the length of the needle, like 
> in the grep command.

1) how about a CTFE find?

s.find!(needle, pred)

If we can initialize boyer-moore or KMP at compile time - it 
should be the fastest!

At ndslice such functions are called bifacial:

http://dlang.org/phobos/std_experimental_ndslice_iteration.html

Imho a lot more in std.algorithm should be able to profit from 
facts known at compile-time.

2) Even for a runtime runtime one-letter needle I am pretty sure 
it's worth to specialize


More information about the Digitalmars-d mailing list