We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2c66e28 commit af990b6Copy full SHA for af990b6
src/external_trait_impls/rayon/set.rs
@@ -198,9 +198,16 @@ where
198
where
199
C: UnindexedConsumer<Self::Item>,
200
{
201
- self.a
+ // We'll iterate one set in full, and only the remaining difference from the other.
202
+ // Use the smaller set for the difference in order to reduce hash lookups.
203
+ let (smaller, larger) = if self.a.len() <= self.b.len() {
204
+ (self.a, self.b)
205
+ } else {
206
+ (self.b, self.a)
207
+ };
208
+ larger
209
.into_par_iter()
- .chain(self.b.par_difference(self.a))
210
+ .chain(smaller.par_difference(larger))
211
.drive_unindexed(consumer)
212
}
213
0 commit comments