Open adetaylor opened 4 years ago
Uses of unsafe:
ptr::copy_nonoverlapping
to assemble the string representation of the integer, from right to left.Given the need to initialize the string from right to left for performance, the only options I see would be:
I wonder if the need for that latter type has shown up anywhere else in safety-dance's audits? Or if anyone has any better ideas?
If you only write byte values 0..=127
then it's impossible to not be valid utf8
and making a new buffer type for this would be pretty trivial since you only need push, not all general buffer methods
itoa
has fast functions for printing integers. It's a dependency ofserde_json
so is included in lots of things. It's by the awesome dtolnay so I suspect it's unlikely we can add safety, but maybe we can identify patterns that can be better supported in future Rust.https://github.com/dtolnay/itoa