rust/library/alloc
bors 4a86c7907b Auto merge of #96605 - Urgau:string-retain-codegen, r=thomcc
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
2022-05-21 01:56:51 +00:00
..
benches Avoid use of rand::thread_rng in stdlib benchmarks 2022-05-02 00:08:21 -07:00
src Auto merge of #96605 - Urgau:string-retain-codegen, r=thomcc 2022-05-21 01:56:51 +00:00
tests Rollup merge of #94126 - ssomers:alloc_prep_1, r=Mark-Simulacrum 2022-05-02 10:41:54 +09:00
Cargo.toml Switch all libraries to the 2021 edition 2021-12-23 19:03:47 +08:00