-
Notifications
You must be signed in to change notification settings - Fork 13.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Define non-panicking UTF encoding methods on char
#52579
Labels
T-libs-api
Relevant to the library API team, which will review and decide on the PR/issue.
Comments
char
char
I wonder, why you just don't provide a 4-byte buffer which will always succeed (even on a embedded platform, that is space for a 4 byte array ;) )
|
Mark-Simulacrum
added a commit
to Mark-Simulacrum/rust
that referenced
this issue
Dec 24, 2019
…oli-obk 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 (rust-lang#52579, rust-lang#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.
Centril
added a commit
to Centril/rust
that referenced
this issue
Dec 24, 2019
…oli-obk 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 (rust-lang#52579, rust-lang#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.
Triage: closing since the associated PR was closed by the lang team. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
i.e.
pub fn encode_utf8(self, &mut [u8]) -> Option<&mut str>
which returnsNone
if buffer too shortPR to follow
The text was updated successfully, but these errors were encountered: