Skip to content

Commit

Permalink
TypedArray::byte_length() doesn't need an FFI call for JsTypedArray
Browse files Browse the repository at this point in the history
  • Loading branch information
dherman committed Jul 12, 2022
1 parent 23a34d2 commit bdf4a41
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions crates/neon/src/types_impl/buffer/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -494,12 +494,7 @@ impl<T: Binary> TypedArray for JsTypedArray<T> {
}

fn byte_length<'cx, C: Context<'cx>>(&self, cx: &mut C) -> usize {
unsafe {
let env = cx.env().to_raw();
let value = self.to_raw();
let info = sys::typedarray::info(env, value);
info.length * std::mem::size_of::<Self::Item>()
}
self.len(cx) * std::mem::size_of::<Self::Item>()
}
}

Expand Down

0 comments on commit bdf4a41

Please sign in to comment.