Skip to content

Commit

Permalink
Merge pull request #160 from waywardmonkeys/clippy-mem_replace_with_d…
Browse files Browse the repository at this point in the history
…efault

clippy: Fix mem_replace_with_default.
  • Loading branch information
sebcrozet authored Sep 9, 2023
2 parents 7155e57 + 468811b commit aa2ef31
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/partitioning/qbvh/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ impl<LeafData: IndexedData> Qbvh<LeafData> {
workspace.to_sort.extend(0..workspace.orig_ids.len());
let root_id = NodeIndex::new(0, 0);

let mut indices = std::mem::replace(&mut workspace.to_sort, vec![]);
let mut indices = std::mem::take(&mut workspace.to_sort);
let (id, aabb) = self.do_recurse_rebalance(&mut indices, workspace, root_id, margin);
workspace.to_sort = indices;

Expand Down
2 changes: 1 addition & 1 deletion src/query/contact_manifolds/contact_manifold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ impl<ManifoldData, ContactData: Default + Copy> ContactManifold<ManifoldData, Co
#[cfg(feature = "dim2")]
let points = self.points.clone();
#[cfg(feature = "dim3")]
let points = std::mem::replace(&mut self.points, Vec::new());
let points = std::mem::take(&mut self.points);
self.points.clear();

ContactManifold {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ pub fn contact_manifolds_composite_shape_composite_shape<'a, ManifoldData, Conta

// Traverse qbvh1 first.
let ls_aabb2_1 = ls_aabb2.transform_by(&pos12).loosened(prediction);
let mut old_manifolds = std::mem::replace(manifolds, Vec::new());
let mut old_manifolds = std::mem::take(manifolds);

let mut leaf_fn1 = |leaf1: &u32| {
composite1.map_part_at(*leaf1, &mut |part_pos1, part_shape1| {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ pub fn contact_manifolds_composite_shape_shape<ManifoldData, ContactData>(

// Traverse qbvh1 first.
let ls_aabb2_1 = shape2.compute_aabb(&pos12).loosened(prediction);
let mut old_manifolds = std::mem::replace(manifolds, Vec::new());
let mut old_manifolds = std::mem::take(manifolds);

let mut leaf1_fn = |leaf1: &u32| {
composite1.map_part_at(*leaf1, &mut |part_pos1, part_shape1| {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pub fn contact_manifold_halfspace_pfm<'a, ManifoldData, ContactData, S2>(

// We do this clone to perform contact tracking and transfer impulses.
// FIXME: find a more efficient way of doing this.
let old_manifold_points = std::mem::replace(&mut manifold.points, Default::default());
let old_manifold_points = std::mem::take(&mut manifold.points);

for i in 0..feature2.num_vertices {
let vtx2 = feature2.vertices[i];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ pub fn contact_manifolds_heightfield_composite_shape<ManifoldData, ContactData>(
let qbvh2 = composite2.qbvh();
let mut stack2 = Vec::new();
let ls_aabb2_1 = qbvh2.root_aabb().transform_by(pos12).loosened(prediction);
let mut old_manifolds = std::mem::replace(manifolds, Vec::new());
let mut old_manifolds = std::mem::take(manifolds);

heightfield1.map_elements_in_local_aabb(&ls_aabb2_1, &mut |leaf1, part1| {
#[cfg(feature = "dim2")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ pub fn contact_manifolds_heightfield_shape<ManifoldData, ContactData>(
*/
// TODO: somehow precompute the Aabb and reuse it?
let ls_aabb2 = shape2.compute_aabb(pos12).loosened(prediction);
let mut old_manifolds = std::mem::replace(manifolds, Vec::new());
let mut old_manifolds = std::mem::take(manifolds);

heightfield1.map_elements_in_local_aabb(&ls_aabb2, &mut |i, part1| {
#[cfg(feature = "dim2")]
Expand Down
4 changes: 2 additions & 2 deletions src/shape/trimesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -575,8 +575,8 @@ impl TriMesh {
.map(|idx| [idx[0] + base_id, idx[1] + base_id, idx[2] + base_id]),
);

let vertices = std::mem::replace(&mut self.vertices, Vec::new());
let indices = std::mem::replace(&mut self.indices, Vec::new());
let vertices = std::mem::take(&mut self.vertices);
let indices = std::mem::take(&mut self.indices);
*self = TriMesh::with_flags(vertices, indices, self.flags);
}

Expand Down
2 changes: 1 addition & 1 deletion src/transformation/convex_hull3/convex_hull.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ fn fix_silhouette_topology(
}

let mut removing = None;
let old_facets_and_idx = std::mem::replace(out_facets_and_idx, Vec::new());
let old_facets_and_idx = std::mem::take(out_facets_and_idx);

for i in 0..old_facets_and_idx.len() {
let facet_id = (loop_start + i) % old_facets_and_idx.len();
Expand Down

0 comments on commit aa2ef31

Please sign in to comment.