diff options
Diffstat (limited to 'cli')
-rw-r--r-- | cli/napi/util.rs | 21 | ||||
-rw-r--r-- | cli/tools/info.rs | 2 |
2 files changed, 4 insertions, 19 deletions
diff --git a/cli/napi/util.rs b/cli/napi/util.rs index ac6145a8f..edf109460 100644 --- a/cli/napi/util.rs +++ b/cli/napi/util.rs @@ -1,23 +1,8 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. - use deno_runtime::deno_napi::*; -use std::cell::Cell; - -unsafe fn get_backing_store_slice( - backing_store: &mut v8::SharedRef<v8::BackingStore>, - byte_offset: usize, - byte_length: usize, -) -> &mut [u8] { - let cells: *const [Cell<u8>] = - &backing_store[byte_offset..byte_offset + byte_length]; - let mut bytes = cells as *mut [u8]; - &mut *bytes -} pub fn get_array_buffer_ptr(ab: v8::Local<v8::ArrayBuffer>) -> *mut u8 { - let mut backing_store = ab.get_backing_store(); - let byte_length = ab.byte_length(); - let mut slice = - unsafe { get_backing_store_slice(&mut backing_store, 0, byte_length) }; - slice.as_mut_ptr() + // SAFETY: Thanks to the null pointer optimization, NonNull<T> and Option<NonNull<T>> are guaranteed + // to have the same size and alignment. + unsafe { std::mem::transmute(ab.data()) } } diff --git a/cli/tools/info.rs b/cli/tools/info.rs index 30ceb98e4..dd820f24f 100644 --- a/cli/tools/info.rs +++ b/cli/tools/info.rs @@ -284,7 +284,7 @@ fn print_tree_node<TWrite: Write>( fn print_children<TWrite: Write>( writer: &mut TWrite, prefix: &str, - children: &Vec<TreeNode>, + children: &[TreeNode], ) -> fmt::Result { const SIBLING_CONNECTOR: char = '├'; const LAST_SIBLING_CONNECTOR: char = '└'; |