]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #67569 - Mark-Simulacrum:opt-char-encode, r=oli-obk
authorMazdak Farrokhzad <twingoow@gmail.com>
Tue, 24 Dec 2019 03:40:02 +0000 (04:40 +0100)
committerGitHub <noreply@github.com>
Tue, 24 Dec 2019 03:40:02 +0000 (04:40 +0100)
Clean up unsafety in char::encode_utf8

This originally started as an attempt to allow LLVM to optimize through
encode_utf8 to detect the try_encode_utf8 case (#52579, #52580), but due to a
typo my conclusion that my optimizations were successful was incorrect.

Furthermore, as far as I can tell, this optimization is probably just not
possible with LLVM today.  This [code](https://rust.godbolt.org/z/JggRj4)
compiles down to a long series of compares, notably, two identical series of
compares. That essentially means that LLVM is today unable to see that these two
ifs are identical and as such can be merged and then realize that no value of
the if condition can result in a call to `please_delete`. As such, for now, we
do not attempt to specifically optimize for that case.


Trivial merge