-
Notifications
You must be signed in to change notification settings - Fork 789
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rework of FindSubstring using iterator instead #565
base: main
Are you sure you want to change the base?
Conversation
1 similar comment
@Hywan In order to check how fast is this implementation compared to the previous one, do you still have the bench test for this #507 (comment)? Thanks in advance :) |
@fflorent No I don't, sorry :-(. |
src/traits.rs
Outdated
@@ -467,25 +467,18 @@ impl<'a,'b> FindSubstring<&'b [u8]> for &'a[u8] { | |||
memchr::memchr(substr[0], self) | |||
} else { | |||
let max = self.len() - substr_len; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add +1
directly to the definition of max
.
src/traits.rs
Outdated
} | ||
|
||
None | ||
let haystack = &self[..max + 1]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And then remove +1
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, thanks!
73021eb
to
6d00f95
Compare
I have committed a banchmark in Here are the results:
So… not really good I would say. There might be tricks to catch up the previous performance, I am doing tests. |
6d00f95
to
e004a52
Compare
Using an iterator would be better for safety and readiness for sure. However I am not able to obtain better performances with the iterator API. It's up to @Geal to decide :-). |
6c99077
to
e7ca818
Compare
fbd7d65
to
cfc19f1
Compare
Use an iterator of Memchr for FindSubstring, accordingly to the discussion in #507.
Don't hesitate to bikeshed. Also I won't be offended if you don't feel that's worthy :).
Florent