summaryrefslogtreecommitdiffstats
path: root/vendor/rayon/src/slice/mergesort.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:32 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:32 +0000
commit4547b622d8d29df964fa2914213088b148c498fc (patch)
tree9fc6b25f3c3add6b745be9a2400a6e96140046e9 /vendor/rayon/src/slice/mergesort.rs
parentReleasing progress-linux version 1.66.0+dfsg1-1~progress7.99u1. (diff)
downloadrustc-4547b622d8d29df964fa2914213088b148c498fc.tar.xz
rustc-4547b622d8d29df964fa2914213088b148c498fc.zip
Merging upstream version 1.67.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/rayon/src/slice/mergesort.rs')
-rw-r--r--vendor/rayon/src/slice/mergesort.rs22
1 files changed, 11 insertions, 11 deletions
diff --git a/vendor/rayon/src/slice/mergesort.rs b/vendor/rayon/src/slice/mergesort.rs
index a24ba65b7..fec309d27 100644
--- a/vendor/rayon/src/slice/mergesort.rs
+++ b/vendor/rayon/src/slice/mergesort.rs
@@ -205,9 +205,8 @@ where
impl<T> Drop for MergeHole<T> {
fn drop(&mut self) {
// `T` is not a zero-sized type, so it's okay to divide by its size.
- let len = (self.end as usize - self.start as usize) / size_of::<T>();
unsafe {
- // TODO 1.47: let len = self.end.offset_from(self.start) as usize;
+ let len = self.end.offset_from(self.start) as usize;
ptr::copy_nonoverlapping(self.start, self.dest, len);
}
}
@@ -491,8 +490,8 @@ where
let dest_l = SendPtr(dest);
let dest_r = SendPtr(dest.add(left_l.len() + right_l.len()));
rayon_core::join(
- || par_merge(left_l, right_l, dest_l.0, is_less),
- || par_merge(left_r, right_r, dest_r.0, is_less),
+ move || par_merge(left_l, right_l, dest_l.get(), is_less),
+ move || par_merge(left_r, right_r, dest_r.get(), is_less),
);
}
// Finally, `s` gets dropped if we used sequential merge, thus copying the remaining elements
@@ -570,7 +569,7 @@ unsafe fn recurse<T, F>(
// After recursive calls finish we'll have to merge chunks `(start, mid)` and `(mid, end)` from
// `src` into `dest`. If the current invocation has to store the result into `buf`, we'll
- // merge chunks from `v` into `buf`, and viceversa.
+ // merge chunks from `v` into `buf`, and vice versa.
//
// Recursive calls flip `into_buf` at each level of recursion. More concretely, `par_merge`
// merges chunks from `buf` into `v` at the first level, from `v` into `buf` at the second
@@ -593,8 +592,8 @@ unsafe fn recurse<T, F>(
let v = SendPtr(v);
let buf = SendPtr(buf);
rayon_core::join(
- || recurse(v.0, buf.0, left, !into_buf, is_less),
- || recurse(v.0, buf.0, right, !into_buf, is_less),
+ move || recurse(v.get(), buf.get(), left, !into_buf, is_less),
+ move || recurse(v.get(), buf.get(), right, !into_buf, is_less),
);
// Everything went all right - recursive calls didn't panic.
@@ -661,16 +660,17 @@ where
// Wrap pointer in SendPtr so that it can be sent to another thread
// See the documentation of SendPtr for a full explanation
let buf = SendPtr(buf);
+ let is_less = &is_less;
v.par_chunks_mut(CHUNK_LENGTH)
.with_max_len(1)
.enumerate()
- .map(|(i, chunk)| {
+ .map(move |(i, chunk)| {
let l = CHUNK_LENGTH * i;
let r = l + chunk.len();
unsafe {
- let buf = buf.0.add(l);
- (l, r, mergesort(chunk, buf, &is_less))
+ let buf = buf.get().add(l);
+ (l, r, mergesort(chunk, buf, is_less))
}
})
.collect::<Vec<_>>()
@@ -731,7 +731,7 @@ mod tests {
check(&[1, 2, 2, 2, 2, 3], &[]);
check(&[], &[1, 2, 2, 2, 2, 3]);
- let ref mut rng = thread_rng();
+ let rng = &mut thread_rng();
for _ in 0..100 {
let limit: u32 = rng.gen_range(1..21);