about summary refs log tree commit diff
path: root/compiler/rustc_codegen_gcc
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-05-21 01:56:51 +0000
committerbors <bors@rust-lang.org>2022-05-21 01:56:51 +0000
commit4a86c7907b1e34d14d742fa4c4202626bb77eddc (patch)
treeca6b724e0a8e3855c2168c58b4ad9796d7d59951 /compiler/rustc_codegen_gcc
parente57884b6e96bede12447e21edcdc92fcac59ee46 (diff)
parenta98abe83eb42b2f537e8a2d7706ba08d9e296f31 (diff)
downloadrust-4a86c7907b1e34d14d742fa4c4202626bb77eddc.tar.gz
rust-4a86c7907b1e34d14d742fa4c4202626bb77eddc.zip
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
Diffstat (limited to 'compiler/rustc_codegen_gcc')
0 files changed, 0 insertions, 0 deletions