Skip to content

Use get_unchecked in str::[r]split_once #89219

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

Merged
merged 1 commit into from
Oct 10, 2021

Conversation

nickkuk
Copy link
Contributor

@nickkuk nickkuk commented Sep 24, 2021

This PR removes indices checking in str::split_once and str::rsplit_once methods.

@rust-highfive
Copy link
Contributor

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Mark-Simulacrum (or someone else) soon.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 24, 2021
@nagisa
Copy link
Member

nagisa commented Sep 24, 2021

This seems reasonable to me. Searcher trait is unsafe to implement with this exact invariant for implementers.

Do you have any examples of the improvements achieved by this change?

@nickkuk
Copy link
Contributor Author

nickkuk commented Sep 25, 2021

Yes, I noticed that current implementation adds panic handling, then I found the reason of this.

Godbolt comparison is here (link was edited for history).

@Mark-Simulacrum Mark-Simulacrum added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 2, 2021
@nickkuk nickkuk force-pushed the str_split_once_get_unchecked branch from 0ba4165 to a35aaa2 Compare October 5, 2021 09:42
@nickkuk
Copy link
Contributor Author

nickkuk commented Oct 5, 2021

I've removed redundant bounds in str::split_once and str::rsplit_once methods only.

@rustbot label -S-waiting-on-author +S-waiting-on-review

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 5, 2021
@Mark-Simulacrum
Copy link
Member

Thanks. I don't think it makes sense to edit unrelated code in this PR anyway.

@bors r+

@bors
Copy link
Collaborator

bors commented Oct 9, 2021

📌 Commit a35aaa2 has been approved by Mark-Simulacrum

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 9, 2021
@bors
Copy link
Collaborator

bors commented Oct 10, 2021

⌛ Testing commit a35aaa2 with merge 0c87288...

@bors
Copy link
Collaborator

bors commented Oct 10, 2021

☀️ Test successful - checks-actions
Approved by: Mark-Simulacrum
Pushing 0c87288 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Oct 10, 2021
@bors bors merged commit 0c87288 into rust-lang:master Oct 10, 2021
@rustbot rustbot added this to the 1.57.0 milestone Oct 10, 2021
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (0c87288): comparison url.

Summary: This benchmark run did not return any relevant changes.

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

@rustbot label: -perf-regression

@nickkuk nickkuk deleted the str_split_once_get_unchecked branch October 10, 2021 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants