Skip to content

Commit

Permalink
shortcut the sub and and
Browse files Browse the repository at this point in the history
  • Loading branch information
irevoire committed Aug 19, 2022
1 parent 95ba91b commit ea2ba1e
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/bitmap/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,12 @@ fn try_simple_multi_op_owned<E>(
let mut iter = bitmaps.into_iter();
match iter.next().transpose()? {
Some(mut lhs) => {
iter.try_for_each(|rhs| rhs.map(|rhs| op(&mut lhs, rhs)))?;
for rhs in iter {
if lhs.is_empty() {
return Ok(lhs);
}
op(&mut lhs, rhs?);
}
Ok(lhs)
}
None => Ok(RoaringBitmap::default()),
Expand All @@ -586,7 +591,13 @@ fn try_simple_multi_op_ref<'a, E>(
let mut iter = bitmaps.into_iter();
match iter.next().transpose()?.cloned() {
Some(mut lhs) => {
iter.try_for_each(|rhs| rhs.map(|rhs| op(&mut lhs, rhs)))?;
for rhs in iter {
if lhs.is_empty() {
return Ok(lhs);
}
op(&mut lhs, rhs?);
}

Ok(lhs)
}
None => Ok(RoaringBitmap::default()),
Expand Down

0 comments on commit ea2ba1e

Please sign in to comment.