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

perf(serde_v8): avoid extra is_array_buffer_view check (#15056)

This commit is contained in:
Divy Srivastava 2022-07-04 07:00:42 +05:30 committed by David Sherret
parent 43043d245f
commit 78d4dedcdb

View file

@ -70,8 +70,7 @@ pub(crate) fn to_ranged_buffer<'s>(
scope: &mut v8::HandleScope<'s>,
value: v8::Local<v8::Value>,
) -> Result<(v8::Local<'s, v8::ArrayBuffer>, Range<usize>), v8::DataError> {
if value.is_array_buffer_view() {
let view: v8::Local<v8::ArrayBufferView> = value.try_into()?;
if let Ok(view) = v8::Local::<v8::ArrayBufferView>::try_from(value) {
let (offset, len) = (view.byte_offset(), view.byte_length());
let buffer = view.buffer(scope).ok_or(v8::DataError::NoData {
expected: "view to have a buffer",