Skip to content

Commit

Permalink
simplify ByteView::new for inlinable slices
Browse files Browse the repository at this point in the history
  • Loading branch information
marvin-j97 committed Jan 25, 2025
1 parent b768c12 commit 245babe
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/byteview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,9 +391,8 @@ impl ByteView {
// SAFETY: We check for inlinability
// so we know the the input slice fits our buffer
unsafe {
let base_ptr = std::ptr::addr_of_mut!(view) as *mut u8;
let prefix_offset = base_ptr.add(std::mem::size_of::<u32>());
std::ptr::copy_nonoverlapping(slice.as_ptr(), prefix_offset, slice_len);
let data_ptr = std::ptr::addr_of_mut!((*view.trailer.short).data) as *mut u8;
std::ptr::copy_nonoverlapping(slice.as_ptr(), data_ptr, slice_len);
}
} else {
unsafe {
Expand Down

0 comments on commit 245babe

Please sign in to comment.