Optimize std::str::Chars::next
and std::str::Chars::next_back
#142038
+145
−75
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Before/after for
next
: https://godbolt.org/z/bqcvaYxz1Before/after for
next_back
: https://godbolt.org/z/MvTeeWKsPstd::sys_common::wtf8::Wtf8CodePoints
will also benefit from this, since it uses the samenext_code_point
andnext_code_point_reverse
functions internally.I also added tests for all codepoints in the range
0..=char::MAX
(including surrogats that can only appear in WTF-8), so the new implementations have been exhaustively tested