Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/external_trait_impls/rayon/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,16 @@ where
where
C: UnindexedConsumer<Self::Item>,
{
self.a
// We'll iterate one set in full, and only the remaining difference from the other.
// Use the smaller set for the difference in order to reduce hash lookups.
let (smaller, larger) = if self.a.len() <= self.b.len() {
(self.a, self.b)
} else {
(self.b, self.a)
};
larger
.into_par_iter()
.chain(self.b.par_difference(self.a))
.chain(smaller.par_difference(larger))
.drive_unindexed(consumer)
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,9 @@ where
/// ```
#[cfg_attr(feature = "inline-more", inline)]
pub fn union<'a>(&'a self, other: &'a Self) -> Union<'a, T, S, A> {
let (smaller, larger) = if self.len() >= other.len() {
// We'll iterate one set in full, and only the remaining difference from the other.
// Use the smaller set for the difference in order to reduce hash lookups.
let (smaller, larger) = if self.len() <= other.len() {
(self, other)
} else {
(other, self)
Expand Down