1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-22 23:34:47 -05:00

perf(core): avoid extra alloc in Deno.core.encode() (#11323)

This commit is contained in:
Aaron O'Mullan 2021-07-08 17:57:57 +02:00 committed by GitHub
parent c76c09e335
commit 01cf8aab9f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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())
}