rust-lang / rust-lang/rust

possibly improve performance of SIMD candidate check in substring search

Open
#157,593 4 comments 6 reactions 1 assignee View on GitHub

@mazam-97 is already working on this.

Since Jun 8, 2026.

C-enhancement T-libs
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

I noticed that the candidate check for SIMD substring search

https://github.com/rust-lang/rust/blob/029c9e18dd1f4668e1d42bb187c1c263dfe20093/library/core/src/str/pattern.rs#L1843-L1855

is using small_slice_eq

https://github.com/rust-lang/rust/blob/029c9e18dd1f4668e1d42bb187c1c263dfe20093/library/core/src/str/pattern.rs#L1914-L1985

This was pulled from memchr a while back. But memchr got an improvement here a few years ago:

https://github.com/BurntSushi/memchr/commit/e77f0bf07ae3445d77776aabe233a9352dd753c5

std might consider adopting this. Note that memchr's infrastructure uses raw pointers everywhere for $reasons, so I'm unsure if that will matter since compilers are weird.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.