From 8911bdb6d0fdda62e4e4f4464c1c7f1ceeca9ac0 Mon Sep 17 00:00:00 2001 From: Aapo Alasuutari Date: Wed, 27 Jul 2022 08:43:30 +0300 Subject: chore(ext/ffi): Remove unnecessary byte_offset conditional slicing (#15320) --- ext/ffi/lib.rs | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) (limited to 'ext') diff --git a/ext/ffi/lib.rs b/ext/ffi/lib.rs index a03bb41d6..4746a5203 100644 --- a/ext/ffi/lib.rs +++ b/ext/ffi/lib.rs @@ -1030,11 +1030,7 @@ fn ffi_parse_pointer_arg( type_error("Invalid FFI ArrayBufferView, expected data in the buffer") })? .get_backing_store(); - if byte_offset > 0 { - &backing_store[byte_offset..] as *const _ as *const u8 - } else { - &backing_store[..] as *const _ as *const u8 - } + &backing_store[byte_offset..] as *const _ as *const u8 } else if let Ok(value) = v8::Local::::try_from(arg) { value.u64_value().0 as usize as *const u8 } else if let Ok(value) = v8::Local::::try_from(arg) { @@ -1592,11 +1588,7 @@ unsafe fn do_ffi_callback( .buffer(scope) .expect("Unable to deserialize result parameter.") .get_backing_store(); - if byte_offset > 0 { - &backing_store[byte_offset..] as *const _ as *const u8 - } else { - &backing_store[..] as *const _ as *const u8 - } + &backing_store[byte_offset..] as *const _ as *const u8 } else if let Ok(value) = v8::Local::::try_from(value) { value.u64_value().0 as usize as *const u8 } else if let Ok(value) = v8::Local::::try_from(value) { @@ -2039,11 +2031,7 @@ where })? .get_backing_store(); let byte_offset = value.byte_offset(); - if byte_offset > 0 { - &backing_store[byte_offset..] as *const _ as *const u8 - } else { - &backing_store[..] as *const _ as *const u8 - } + &backing_store[byte_offset..] as *const _ as *const u8 } else if let Ok(value) = v8::Local::::try_from(buf.v8_value) { let backing_store = value.get_backing_store(); -- cgit v1.2.3