Open samuelcolvin opened 4 months ago
I'm keen to try and work on this.
Thanks @samuelcolvin
I think in general the basic requirement for performance optimizations in this crate is benchmarks that show performance improvements to justify the additional code complexity / maintenance burden.
I think there are already several cargo bench
style benchmarks for string operations -- maybe a good first step would be to review them and add any additional cases you think are not covered that would benefit from the optimizations described above
I think @Dandandan and @jhorstmann are especailly execited by low level optimizations like this 😁
While working on this, I found #6145, we should merge that, then rebase and review the other PRs here.
The main context for this is well described by https://github.com/BurntSushi/memchr/pull/156.
I think (in rough order of impact) we should:
str.contains
to memchrstr.starts_with
to to hopefullymemchr
, otherwisequick_strings::starts_with
- there's no "what if the haystack is very long" concern since we're looking at the start of the string, so the difference betweenmemchr
andquick_strings
won't be as big, or even might be negativestarts_with_ignore_ascii_case
toquick_strings::istarts_with
*ends_with
quick_strings::icontains
(copying the code) forILIKE
- maybe we have to check it's actually faster for large haystacks? - this might have the biggest impact in some scenarois, but me should be carefulstr.contains
etc inlike.rs
to usePredicate
(I'm not suggesting that we make
quick_strings
a dependency, it was just a scratch experiment, if we use any of that code we should copy it.