mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-01 06:51:58 +00:00
4a86c7907b
Improve codegen of String::retain method This pull-request improve the codegen of the `String::retain` method. Using `unwrap_unchecked` helps the optimizer to not generate a panicking path that will never be taken for valid UTF-8 like string. Using `encode_utf8` saves us from an expensive call to `memcpy`, as the optimizer is unable to realize that `ch_len <= 4` and so can generate much better assembly code. https://rust.godbolt.org/z/z73ohenfc |
||
---|---|---|
.. | ||
benches | ||
src | ||
tests | ||
Cargo.toml |