1
0
mirror of https://github.com/nushell/nushell.git synced 2025-07-12 04:15:57 +02:00

avoid unnecessary allocation ()

This commit is contained in:
Andrew Houts
2021-12-05 12:38:58 -06:00
committed by GitHub
parent c08e145501
commit ee9eddd851

@ -925,11 +925,8 @@ fn escape_char<W>(wr: &mut W, value: char) -> Result<()>
where where
W: io::Write, W: io::Write,
{ {
// FIXME: this allocation is required in order to be compatible with stable let mut scratch = [0_u8; 4];
// rust, which doesn't support encoding a `char` into a stack buffer. escape_bytes(wr, value.encode_utf8(&mut scratch).as_bytes())
let mut s = String::new();
s.push(value);
escape_bytes(wr, s.as_bytes())
} }
fn fmt_f32_or_null<W>(wr: &mut W, value: f32) -> Result<()> fn fmt_f32_or_null<W>(wr: &mut W, value: f32) -> Result<()>