mirror of
https://github.com/denoland/deno.git
synced 2024-12-22 07:14:47 -05:00
perf: micro-optimize core.encode (#14120)
This commit is contained in:
parent
37b0ec454c
commit
b18216a0d4
1 changed files with 7 additions and 3 deletions
|
@ -864,9 +864,13 @@ fn encode(
|
|||
}
|
||||
};
|
||||
let text_str = text.to_rust_string_lossy(scope);
|
||||
let zbuf: ZeroCopyBuf = text_str.into_bytes().into();
|
||||
|
||||
rv.set(to_v8(scope, zbuf).unwrap())
|
||||
let bytes: Box<[u8]> = text_str.into_bytes().into_boxed_slice();
|
||||
let len = bytes.len();
|
||||
let backing_store =
|
||||
v8::ArrayBuffer::new_backing_store_from_boxed_slice(bytes).make_shared();
|
||||
let buffer = v8::ArrayBuffer::with_backing_store(scope, &backing_store);
|
||||
let u8array = v8::Uint8Array::new(scope, buffer, 0, len).unwrap();
|
||||
rv.set(u8array.into())
|
||||
}
|
||||
|
||||
fn decode(
|
||||
|
|
Loading…
Reference in a new issue