From ef24de24a82fe681581cc130f342363c47c0969a Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 7 Jun 2024 07:48:48 +0200 Subject: Merging upstream version 1.75.0+dfsg1. Signed-off-by: Daniel Baumann --- vendor/rayon/src/iter/extend.rs | 10 +++++++ vendor/rayon/src/iter/from_par_iter.rs | 51 ++++++++++++++++++++++++++++++++++ vendor/rayon/src/iter/mod.rs | 10 +++---- vendor/rayon/src/iter/par_bridge.rs | 5 ++++ vendor/rayon/src/iter/product.rs | 2 +- vendor/rayon/src/iter/sum.rs | 2 +- 6 files changed, 73 insertions(+), 7 deletions(-) (limited to 'vendor/rayon/src/iter') diff --git a/vendor/rayon/src/iter/extend.rs b/vendor/rayon/src/iter/extend.rs index 1769d476b..a2645280f 100644 --- a/vendor/rayon/src/iter/extend.rs +++ b/vendor/rayon/src/iter/extend.rs @@ -500,6 +500,16 @@ impl ParallelExtend for String { } } +/// Extends a string with boxed strings from a parallel iterator. +impl ParallelExtend> for String { + fn par_extend(&mut self, par_iter: I) + where + I: IntoParallelIterator>, + { + extend!(self, par_iter, string_extend); + } +} + /// Extends a string with string slices from a parallel iterator. impl<'a> ParallelExtend> for String { fn par_extend(&mut self, par_iter: I) diff --git a/vendor/rayon/src/iter/from_par_iter.rs b/vendor/rayon/src/iter/from_par_iter.rs index 3240f32e2..49afd6cb8 100644 --- a/vendor/rayon/src/iter/from_par_iter.rs +++ b/vendor/rayon/src/iter/from_par_iter.rs @@ -6,6 +6,8 @@ use std::collections::LinkedList; use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet}; use std::collections::{BinaryHeap, VecDeque}; use std::hash::{BuildHasher, Hash}; +use std::rc::Rc; +use std::sync::Arc; /// Creates an empty default collection and extends it. fn collect_extended(par_iter: I) -> C @@ -31,6 +33,45 @@ where } } +/// Collects items from a parallel iterator into a boxed slice. +impl FromParallelIterator for Box<[T]> +where + T: Send, +{ + fn from_par_iter(par_iter: I) -> Self + where + I: IntoParallelIterator, + { + Vec::from_par_iter(par_iter).into() + } +} + +/// Collects items from a parallel iterator into a reference-counted slice. +impl FromParallelIterator for Rc<[T]> +where + T: Send, +{ + fn from_par_iter(par_iter: I) -> Self + where + I: IntoParallelIterator, + { + Vec::from_par_iter(par_iter).into() + } +} + +/// Collects items from a parallel iterator into an atomically-reference-counted slice. +impl FromParallelIterator for Arc<[T]> +where + T: Send, +{ + fn from_par_iter(par_iter: I) -> Self + where + I: IntoParallelIterator, + { + Vec::from_par_iter(par_iter).into() + } +} + /// Collects items from a parallel iterator into a vecdeque. impl FromParallelIterator for VecDeque where @@ -174,6 +215,16 @@ impl FromParallelIterator for String { } } +/// Collects boxed strings from a parallel iterator into one large string. +impl FromParallelIterator> for String { + fn from_par_iter(par_iter: I) -> Self + where + I: IntoParallelIterator>, + { + collect_extended(par_iter) + } +} + /// Collects string slices from a parallel iterator into a string. impl<'a> FromParallelIterator> for String { fn from_par_iter(par_iter: I) -> Self diff --git a/vendor/rayon/src/iter/mod.rs b/vendor/rayon/src/iter/mod.rs index e60ea1633..7b5a29aeb 100644 --- a/vendor/rayon/src/iter/mod.rs +++ b/vendor/rayon/src/iter/mod.rs @@ -1547,7 +1547,7 @@ pub trait ParallelIterator: Sized + Send { /// Computes the maximum of all the items in the iterator with respect to /// the given comparison function. If the iterator is empty, `None` is - /// returned; otherwise, `Some(min)` is returned. + /// returned; otherwise, `Some(max)` is returned. /// /// Note that the order in which the items will be reduced is not /// specified, so if the comparison function is not associative, then @@ -2392,7 +2392,7 @@ impl IntoParallelIterator for T { #[allow(clippy::len_without_is_empty)] pub trait IndexedParallelIterator: ParallelIterator { /// Collects the results of the iterator into the specified - /// vector. The vector is always truncated before execution + /// vector. The vector is always cleared before execution /// begins. If possible, reusing the vector across calls can lead /// to better performance since it reuses the same backing buffer. /// @@ -2401,7 +2401,7 @@ pub trait IndexedParallelIterator: ParallelIterator { /// ``` /// use rayon::prelude::*; /// - /// // any prior data will be truncated + /// // any prior data will be cleared /// let mut vec = vec![-1, -2, -3]; /// /// (0..5).into_par_iter() @@ -2414,7 +2414,7 @@ pub trait IndexedParallelIterator: ParallelIterator { } /// Unzips the results of the iterator into the specified - /// vectors. The vectors are always truncated before execution + /// vectors. The vectors are always cleared before execution /// begins. If possible, reusing the vectors across calls can lead /// to better performance since they reuse the same backing buffer. /// @@ -2423,7 +2423,7 @@ pub trait IndexedParallelIterator: ParallelIterator { /// ``` /// use rayon::prelude::*; /// - /// // any prior data will be truncated + /// // any prior data will be cleared /// let mut left = vec![42; 10]; /// let mut right = vec![-1; 10]; /// diff --git a/vendor/rayon/src/iter/par_bridge.rs b/vendor/rayon/src/iter/par_bridge.rs index 8398274b3..eb058d3e6 100644 --- a/vendor/rayon/src/iter/par_bridge.rs +++ b/vendor/rayon/src/iter/par_bridge.rs @@ -13,6 +13,11 @@ use crate::{current_num_threads, current_thread_index}; /// `par_iter` instead. However, it can still be useful for iterators that are difficult to /// parallelize by other means, like channels or file or network I/O. /// +/// Iterator items are pulled by `next()` one at a time, synchronized from each thread that is +/// ready for work, so this may become a bottleneck if the serial iterator can't keep up with the +/// parallel demand. The items are not buffered by `IterBridge`, so it's fine to use this with +/// large or even unbounded iterators. +/// /// The resulting iterator is not guaranteed to keep the order of the original iterator. /// /// # Examples diff --git a/vendor/rayon/src/iter/product.rs b/vendor/rayon/src/iter/product.rs index a3d0727f9..e081be06b 100644 --- a/vendor/rayon/src/iter/product.rs +++ b/vendor/rayon/src/iter/product.rs @@ -13,7 +13,7 @@ where } fn mul(left: T, right: T) -> T { - iter::once(left).chain(iter::once(right)).product() + [left, right].into_iter().product() } struct ProductConsumer { diff --git a/vendor/rayon/src/iter/sum.rs b/vendor/rayon/src/iter/sum.rs index a73e0bf3d..ddae810f9 100644 --- a/vendor/rayon/src/iter/sum.rs +++ b/vendor/rayon/src/iter/sum.rs @@ -13,7 +13,7 @@ where } fn add(left: T, right: T) -> T { - iter::once(left).chain(iter::once(right)).sum() + [left, right].into_iter().sum() } struct SumConsumer { -- cgit v1.2.3