str: add ASCII fast path to word_to_titlecase#159271
Conversation
|
Thanks for the pull request, and welcome! The Rust Project is excited to review your changes, and you should hear from @clarfonthey (or someone else) some time within the next two weeks. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
621e917 to
ac53b43
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
Finally got to reviewing this, new tests look good, and I think this should be fine. Thank you! @bors r+ rollup |
…tpath, r=clarfonthey str: add ASCII fast path to word_to_titlecase The word_to_titlecase function had a FIXME comment since a long time asking to add a fast path for ASCII text. Before this change, even simple English text like "hello world" was going through slow Unicode lookup tables. That was unnecessary. This fixes it by using the same trick that to_lowercase already uses — plain English letters are now handled much faster, and only Greek/Chinese/etc still use the Unicode tables. No behavior changes, just faster for normal English text.
Rollup of 12 pull requests Successful merges: - #159765 (Avoid spurious rebuilds of JSON docs in bootstrap) - #159781 (Update bootstrap to use -Zembed-metadata=no instead of -Zno-embed-metadata) - #158362 (trait solver: account for universes from replace_bound_vars) - #159173 (Add allowed list check on EII implementations attributes) - #159718 (Make `DocLinkResMap` an `FxIndexMap`) - #159722 ( [rustdoc] Retrieve `cfg_attr` information for derived impls for `doc_cfg` feature) - #155795 (constify `vec![1, 2, 3]` macro) - #157776 (ci: Enable autodiff tests on x86_64 linux) - #158766 (Promote riscv64-unknown-linux-musl to tier 2 with host tools) - #159271 (str: add ASCII fast path to word_to_titlecase) - #159666 (fix(ld64.lld): route version mismatch warnings to linker_info on macOS) - #159667 (Make some parser structured suggestions verbose and tweak their wording)
Rollup of 14 pull requests Successful merges: - #159765 (Avoid spurious rebuilds of JSON docs in bootstrap) - #159781 (Update bootstrap to use -Zembed-metadata=no instead of -Zno-embed-metadata) - #158362 (trait solver: account for universes from replace_bound_vars) - #158372 (rustfmt: Discover modules via `cfg_select!`) - #159173 (Add allowed list check on EII implementations attributes) - #159718 (Make `DocLinkResMap` an `FxIndexMap`) - #159722 ( [rustdoc] Retrieve `cfg_attr` information for derived impls for `doc_cfg` feature) - #159731 (std: Implement futex on wasip3 targets, update target spec) - #159755 (Improve consistency of attribute error messages) - #155795 (constify `vec![1, 2, 3]` macro) - #157776 (ci: Enable autodiff tests on x86_64 linux) - #158766 (Promote riscv64-unknown-linux-musl to tier 2 with host tools) - #159271 (str: add ASCII fast path to word_to_titlecase) - #159667 (Make some parser structured suggestions verbose and tweak their wording)
Rollup merge of #159271 - Rachit2323:fix-titlecase-ascii-fastpath, r=clarfonthey str: add ASCII fast path to word_to_titlecase The word_to_titlecase function had a FIXME comment since a long time asking to add a fast path for ASCII text. Before this change, even simple English text like "hello world" was going through slow Unicode lookup tables. That was unnecessary. This fixes it by using the same trick that to_lowercase already uses — plain English letters are now handled much faster, and only Greek/Chinese/etc still use the Unicode tables. No behavior changes, just faster for normal English text.
The word_to_titlecase function had a FIXME comment since a long time asking to add a fast path for ASCII text.
Before this change, even simple English text like "hello world" was going through slow Unicode lookup tables. That was unnecessary.
This fixes it by using the same trick that to_lowercase already uses — plain English letters are now handled much faster, and only Greek/Chinese/etc still use the Unicode tables.
No behavior changes, just faster for normal English text.