From 01cf8aab9f7dd3d5e33a8b36d576ac575b5dfd0e Mon Sep 17 00:00:00 2001 From: Aaron O'Mullan Date: Thu, 8 Jul 2021 17:57:57 +0200 Subject: perf(core): avoid extra alloc in Deno.core.encode() (#11323) --- core/bindings.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'core') 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()) } -- cgit v1.2.3