Skip to content

Optimize core::str::Chars::count #90414

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 5 commits into from
Feb 6, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix comment grammar for do_count_chars
thomcc committed Feb 5, 2022

Unverified

This user has not yet uploaded their public signing key.
commit 41f821461f0235912501a58feb0d86c58167a015
2 changes: 1 addition & 1 deletion library/core/src/str/count.rs
Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@ fn do_count_chars(s: &str) -> usize {
//
// - Less than or equal to 255, otherwise we'll overflow bytes in `counts`.
// - A multiple of `UNROLL_INNER`, otherwise our `break` inside the
// `body.chunks(CHUNK_SIZE)` loop.
// `body.chunks(CHUNK_SIZE)` loop is incorrect.
//
// For performance, `CHUNK_SIZE` should be:
// - Relatively cheap to `/` against (so some simple sum of powers of two).