diff options
author | Aaron O'Mullan <aaron.omullan@gmail.com> | 2021-07-08 17:57:57 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-08 17:57:57 +0200 |
commit | 01cf8aab9f7dd3d5e33a8b36d576ac575b5dfd0e (patch) | |
tree | 47305f2dc65119f5bcb73e0ea14813bb091bae13 | |
parent | c76c09e3354bc3aedc6de94f177f92c2c96593d6 (diff) |
perf(core): avoid extra alloc in Deno.core.encode() (#11323)
-rw-r--r-- | core/bindings.rs | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/core/bindings.rs b/core/bindings.rs index d8337322d..9ece23276 100644 --- a/core/bindings.rs +++ b/core/bindings.rs @@ -655,9 +655,8 @@ fn encode( } }; let text_str = text.to_rust_string_lossy(scope); - let text_bytes = text_str.as_bytes().to_vec().into_boxed_slice(); + let zbuf: ZeroCopyBuf = text_str.into_bytes().into(); - let zbuf: ZeroCopyBuf = text_bytes.into(); rv.set(to_v8(scope, zbuf).unwrap()) } |