Skip to content

Optimize slice {Chunks,Windows}::nth #138562

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 3 commits into from
Apr 6, 2025
Merged

Conversation

kornelski
Copy link
Contributor

I've noticed that the nth functions on slice iters had non-optimized-out bounds checks.

The new implementation even generates branchless code.

@rustbot
Copy link
Collaborator

rustbot commented Mar 16, 2025

r? @Noratrieb

rustbot has assigned @Noratrieb.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Mar 16, 2025
@Noratrieb Noratrieb changed the title Optimize slice Iter::nth Optimize slice {Chunks,Windows}::nth Mar 24, 2025
Copy link
Member

@Noratrieb Noratrieb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, one small comment and then we can merge it. I also renamed your PR to be more accurate

@Noratrieb Noratrieb 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 Mar 24, 2025
Generates branchless code
This avoids generating extra instructions that needlessly modify the slice's pointer
@Noratrieb
Copy link
Member

@bors r+

@bors
Copy link
Collaborator

bors commented Apr 6, 2025

📌 Commit 9f2f1aa has been approved by Noratrieb

It is now in the queue for this repository.

@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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 6, 2025
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 6, 2025
…llaumeGomez

Rollup of 6 pull requests

Successful merges:

 - rust-lang#138562 (Optimize slice {Chunks,Windows}::nth)
 - rust-lang#138876 (Trusty: Implement `write_vectored` for stdio )
 - rust-lang#139072 (Add `slice::align_to_uninit_mut`)
 - rust-lang#139367 (Add `*_value` methods to proc_macro lib)
 - rust-lang#139391 (Check if merged attributes list is empty in expr)
 - rust-lang#139414 (Fix typo in `RawList`'s documentation)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 7bd89b9 into rust-lang:master Apr 6, 2025
6 checks passed
@rustbot rustbot added this to the 1.88.0 milestone Apr 6, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Apr 6, 2025
Rollup merge of rust-lang#138562 - kornelski:nth-panic, r=Noratrieb

Optimize slice {Chunks,Windows}::nth

I've noticed that the `nth` functions on slice iters had non-optimized-out bounds checks.

The new implementation even generates branchless code.
github-actions bot pushed a commit to model-checking/verify-rust-std that referenced this pull request Apr 11, 2025
Optimize slice {Chunks,Windows}::nth

I've noticed that the `nth` functions on slice iters had non-optimized-out bounds checks.

The new implementation even generates branchless code.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants