Skip to content

Optimize slice::contains for one-byte BytewiseEq types - #160732

Merged
rust-bors[bot] merged 3 commits into
rust-lang:mainfrom
SomeFlyingThing:agent/optimize-bytewise-contains
Aug 9, 2026
Merged

Optimize slice::contains for one-byte BytewiseEq types#160732
rust-bors[bot] merged 3 commits into
rust-lang:mainfrom
SomeFlyingThing:agent/optimize-bytewise-contains

Conversation

@SomeFlyingThing

Copy link
Copy Markdown
Contributor

add optimized searches for NonZeroI8, option ordering, and other one-byte types

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Aug 8, 2026
@rustbot

rustbot commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator

r? @clarfonthey

rustbot has assigned @clarfonthey.
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

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: libs
  • libs expanded to 12 candidates
  • Random selection from JohnTitor, Mark-Simulacrum, clarfonthey, nia-e

@joboet joboet left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks fine, thank you!

View changes since this review

Comment thread library/core/src/slice/cmp.rs Outdated
// slice can be read as `u8`s.
let (byte, bytes) = unsafe {
(
*(self as *const Self).cast::<u8>(),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

A style suggestion: why not use transmute_copy here?

Suggested change
*(self as *const Self).cast::<u8>(),
transmute_copy::<T, u8>(self)

@clarfonthey

Copy link
Copy Markdown
Contributor

r? joboet

@rustbot rustbot assigned joboet and unassigned clarfonthey Aug 8, 2026
@rustbot

rustbot commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator

joboet is currently at their maximum review capacity.
They may take a while to respond.

@rust-log-analyzer

This comment has been minimized.

@clarfonthey

Copy link
Copy Markdown
Contributor

@bors r=joboet

Thank you!

@rust-bors

rust-bors Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 538b303 has been approved by joboet

It is now in the queue for this repository.

@rust-bors rust-bors Bot 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 Aug 8, 2026
rust-bors Bot pushed a commit that referenced this pull request Aug 8, 2026
…uwer

Rollup of 9 pull requests

Successful merges:

 - #156935 (Introduce a `PinSafePointer` trait that generalizes `PinCoerceUnsized`)
 - #159834 (Apply str debugger visualizer to `*const str`, `*mut str` and `Box<str>`)
 - #160663 (Suggest add async for function sig with return expr in body)
 - #160732 (Optimize slice::contains for one-byte BytewiseEq types)
 - #157944 (Make `char::is_default_ignorable` unstably public)
 - #158835 (rustc_passes: lint unused `#[path]` attributes on inline modules)
 - #160754 (Rename more diagnostic files to `diagnostics.rs`)
 - #160755 (Merge `rustc_lint/lints.rs` into `diagnostics.rs`)
 - #160757 (Merge `rustc_attr_parsing/session_diagnostics.rs` into `diagnostics.rs`)
@rust-bors
rust-bors Bot merged commit cc2a0a4 into rust-lang:main Aug 9, 2026
13 checks passed
@rustbot rustbot added this to the 1.99.0 milestone Aug 9, 2026
rust-timer added a commit that referenced this pull request Aug 9, 2026
Rollup merge of #160732 - SomeFlyingThing:agent/optimize-bytewise-contains, r=joboet

Optimize slice::contains for one-byte BytewiseEq types

add optimized searches for NonZeroI8, option<NonZeroI8> ordering, and other one-byte types
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-compiler Relevant to the compiler team, which will review and decide on the PR/issue. 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