String search for String
#14099
dbuenzli
started this conversation in
Show and tell
Replies: 2 comments
-
I am in favour of having this in the standard library. |
Beta Was this translation helpful? Give feedback.
0 replies
-
I tend to agree that we should benchmark a few variation of string searches and choose a reasonable version. I had started to have a look at benchmarking too at https://github.com/Octachron/needle-benchmark . |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
As mentioned in PR #14068 it has been on my mind for sometime to add a few handy string search functions to the
String
module.In this gist I have implemented primitives for string searching with both naive string search and the two way algorithm1 and functions that I'd like to see in
String
.A toy benchmark that compares both algorithms seems to indicates that we could simply go with this without special casing small needles (at least as far as I'm concerned, it seems to show good all round behaviour). If you have
hyperfine
andocamlopt
in yourPATH
you can try it with:If there is interest in upstreaming I think a strategy could be to start with
[r]find_sub
and the underlying primitives and then make other PRs to bikeshed the other functions. However while I have a good idea on how the algorithm works now there remains one or two index computations that I cargo culted that I'd prefer to fully absorb before – but I won't bother if upstream is not interested.Footnotes
The paper (warning indices are one-based) and a high-level description and C code. ↩
Beta Was this translation helpful? Give feedback.
All reactions