diff --git a/lib/api/src/js/ptr.rs b/lib/api/src/js/ptr.rs index 28f87f00c..e5c0c471b 100644 --- a/lib/api/src/js/ptr.rs +++ b/lib/api/src/js/ptr.rs @@ -86,13 +86,6 @@ impl WasmPtr { } } -#[inline(always)] -fn align_pointer(ptr: usize, align: usize) -> usize { - // clears bits below aligment amount (assumes power of 2) to align pointer - debug_assert!(align.count_ones() == 1); - ptr & !(align - 1) -} - /// Methods for `WasmPtr`s to data that can be dereferenced, namely to types /// that implement [`ValueType`], meaning that they're valid for all possible /// bit patterns. @@ -109,8 +102,7 @@ impl WasmPtr { if total_len > memory.size().bytes().0 || mem::size_of::() == 0 { return None; } - let offset = align_pointer(self.offset as usize, mem::align_of::()) as u32; - let subarray = memory.uint8view().subarray(offset, total_len as u32); + let subarray = memory.uint8view().subarray(self.offset, total_len as u32); Some(WasmCell::new(subarray)) } } @@ -140,14 +132,13 @@ impl WasmPtr { return None; } - let offset = align_pointer(self.offset as usize, mem::align_of::()) as u32; - Some( (0..length) .map(|i| { - let subarray = memory - .uint8view() - .subarray(offset + i * item_size, offset + (i + 1) * item_size); + let subarray = memory.uint8view().subarray( + self.offset + i * item_size, + self.offset + (i + 1) * item_size, + ); WasmCell::new(subarray) }) .collect::>(),