Skip to content

Commit

Permalink
Move dst argument after src
Browse files Browse the repository at this point in the history
  • Loading branch information
ttencate committed Feb 3, 2025
1 parent 28bbd0d commit 4fbdef2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions godot-core/src/builtin/collections/packed_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ macro_rules! impl_packed_array {
/// * `src` must not point to `self` data.
/// * `len` must be equal to `self.len() - dst`.
/// * Source data must not be dropped later.
unsafe fn move_from_slice(&mut self, dst: usize, src: *const $Element, len: usize) {
unsafe fn move_from_slice(&mut self, src: *const $Element, dst: usize, len: usize) {
let ptr = self.ptr_mut(dst);
debug_assert_eq!(len, self.len() - dst, "length precondition violated");
// Drops all elements in place. Drop impl must not panic.
Expand Down Expand Up @@ -460,7 +460,7 @@ macro_rules! impl_packed_array {

// SAFETY: The packed array contains exactly N elements and the source array will be forgotten.
unsafe {
packed_array.move_from_slice(0, arr.as_ptr(), N);
packed_array.move_from_slice(arr.as_ptr(), 0, N);
}
packed_array
}
Expand All @@ -479,7 +479,7 @@ macro_rules! impl_packed_array {
// The vector is forcibly set to empty, so its contents are forgotten.
unsafe {
vec.set_len(0);
array.move_from_slice(0, vec.as_ptr(), len);
array.move_from_slice(vec.as_ptr(), 0, len);
}
array
}
Expand Down Expand Up @@ -595,7 +595,7 @@ macro_rules! impl_packed_array {
// SAFETY: Dropping the first `buf_slice.len()` items is safe, because those are exactly the ones we initialized.
// Writing output is safe because we just allocated `buf_slice.len()` new elements after index `len`.
unsafe {
self.move_from_slice(len, buf_slice.as_ptr(), buf_slice.len());
self.move_from_slice(buf_slice.as_ptr(), len, buf_slice.len());
}

len = capacity;
Expand Down

0 comments on commit 4fbdef2

Please sign in to comment.