Skip to content

Commit

Permalink
reimplement Mat clone_from without copy_from but with better formatti…
Browse files Browse the repository at this point in the history
…ng.rs
  • Loading branch information
8000thCube authored and sarah-ek committed Sep 7, 2024
1 parent c316ec7 commit d3f32fa
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/mat/matown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2072,7 +2072,14 @@ impl<E: Entity> Clone for Mat<E> {
}

fn clone_from(&mut self, other: &Self) {
self.copy_from(other);
let (rows, cols)=other.shape();
self.resize_with(0, 0, |_, _| E::zeroed());
self.resize_with(
rows,
cols,
#[inline(always)]
|row, col| unsafe { other.read_unchecked(row, col) },
);
}
}

Expand Down

0 comments on commit d3f32fa

Please sign in to comment.