mirror of
https://github.com/nushell/nushell
synced 2024-12-26 13:03:07 +00:00
avoid unnecessary allocation (#4178)
This commit is contained in:
parent
c08e145501
commit
ee9eddd851
1 changed files with 2 additions and 5 deletions
|
@ -925,11 +925,8 @@ fn escape_char<W>(wr: &mut W, value: char) -> Result<()>
|
|||
where
|
||||
W: io::Write,
|
||||
{
|
||||
// FIXME: this allocation is required in order to be compatible with stable
|
||||
// rust, which doesn't support encoding a `char` into a stack buffer.
|
||||
let mut s = String::new();
|
||||
s.push(value);
|
||||
escape_bytes(wr, s.as_bytes())
|
||||
let mut scratch = [0_u8; 4];
|
||||
escape_bytes(wr, value.encode_utf8(&mut scratch).as_bytes())
|
||||
}
|
||||
|
||||
fn fmt_f32_or_null<W>(wr: &mut W, value: f32) -> Result<()>
|
||||
|
|
Loading…
Reference in a new issue