mirror of
https://github.com/nushell/nushell
synced 2024-11-10 15:14:14 +00:00
remove extra allocation from nu-json (#8299)
# Description Remove unnecessary memory allocation # User-Facing Changes None # Tests + Formatting Don't forget to add tests that cover your changes. Make sure you've run and fixed any issues with these commands: - `cargo fmt --all -- --check` to check standard code formatting (`cargo fmt --all` applies these changes) - `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect` to check that you're using the standard code style - `cargo test --workspace` to check that all tests pass # After Submitting If your PR had any user-facing changes, update [the documentation](https://github.com/nushell/nushell.github.io) after the PR is merged, if necessary. This will help us keep the docs up to date. Co-authored-by: None <>
This commit is contained in:
parent
6148314dcd
commit
bd096430cb
1 changed files with 1 additions and 5 deletions
|
@ -856,11 +856,7 @@ 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())
|
||||
escape_bytes(wr, value.encode_utf8(&mut [0; 4]).as_bytes())
|
||||
}
|
||||
|
||||
fn fmt_f32_or_null<W>(wr: &mut W, value: f32) -> Result<()>
|
||||
|
|
Loading…
Reference in a new issue