Skip to content

Commit

Permalink
Fixed clone of raw data
Browse files Browse the repository at this point in the history
  • Loading branch information
YohDeadfall committed Aug 26, 2024
1 parent e396630 commit 1d7a6c4
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions src/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,21 +292,10 @@ impl<const N: usize> UpperHex for RawOrdPath<N> {

impl<const N: usize> Clone for RawOrdPath<N> {
fn clone(&self) -> Self {
unsafe {
if self.meta.on_heap() {
// SAFETY: Safe becuase the clone has the same length.
let mut other = Self::new(self.len()).unwrap_unchecked();
self.as_ptr()
.copy_to_nonoverlapping(other.as_mut_ptr() as *mut u8, self.len());

other
} else {
Self {
meta: self.meta,
data: RawOrdPathData::new_inline(self.data.inline),
}
}
}
let mut other = Self::new(self.len()).unwrap();
other.as_mut_slice().clone_from_slice(self.as_slice());
other.set_trailing_bits(self.trailing_bits());
other
}
}

Expand Down

0 comments on commit 1d7a6c4

Please sign in to comment.