Skip to content

Commit

Permalink
Make clippy happy
Browse files Browse the repository at this point in the history
  • Loading branch information
Kerollmops committed Jan 7, 2025
1 parent 0dcd67a commit 4dfd47b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
8 changes: 5 additions & 3 deletions roaring/src/bitmap/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,7 @@ impl Extend<u32> for RoaringBitmap {
/// assert!(rb.contains(1508));
/// assert!(!rb.contains(5));
/// ```
#[inline]
fn extend<I: IntoIterator<Item = u32>>(&mut self, values: I) {
let mut values = values.into_iter();
let value = match values.next() {
Expand All @@ -742,18 +743,18 @@ impl Extend<u32> for RoaringBitmap {
let (mut currenthb, lowbit) = util::split(value);
let mut current_container_index = self.find_container_by_key(currenthb);
let mut current_cont = &mut self.containers[current_container_index];
current_cont.insert(lowbit) as u64;
current_cont.insert(lowbit);

for val in values {
let (newhb, lowbit) = util::split(val);
if currenthb == newhb {
// easy case, this could be quite frequent
current_cont.insert(lowbit) as u64;
current_cont.insert(lowbit);
} else {
currenthb = newhb;
current_container_index = self.find_container_by_key(currenthb);
current_cont = &mut self.containers[current_container_index];
current_cont.insert(lowbit) as u64;
current_cont.insert(lowbit);
}
}
}
Expand All @@ -777,6 +778,7 @@ impl<'a> Extend<&'a u32> for RoaringBitmap {
/// assert!(rb.contains(1508));
/// assert!(!rb.contains(5));
/// ```
#[inline]
fn extend<I: IntoIterator<Item = &'a u32>>(&mut self, values: I) {
self.extend(values.into_iter().copied());
}
Expand Down
6 changes: 3 additions & 3 deletions roaring/src/bitmap/store/bitmap_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ impl BitmapStore {
pub fn insert(&mut self, index: u16) -> bool {
let (key, bit) = (key(index), bit(index));
let old_w = self.bits[key];
let new_w = old_w | 1 << bit;
let new_w = old_w | (1 << bit);
let inserted = (old_w ^ new_w) >> bit; // 1 or 0
self.bits[key] = new_w;
self.len += inserted;
Expand Down Expand Up @@ -634,7 +634,7 @@ impl BitOrAssign<&ArrayStore> for BitmapStore {
for &index in rhs.iter() {
let (key, bit) = (key(index), bit(index));
let old_w = self.bits[key];
let new_w = old_w | 1 << bit;
let new_w = old_w | (1 << bit);
self.len += (old_w ^ new_w) >> bit;
self.bits[key] = new_w;
}
Expand Down Expand Up @@ -679,7 +679,7 @@ impl BitXorAssign<&ArrayStore> for BitmapStore {
for &index in rhs.iter() {
let (key, bit) = (key(index), bit(index));
let old_w = self.bits[key];
let new_w = old_w ^ 1 << bit;
let new_w = old_w ^ (1 << bit);
len += 1 - 2 * (((1 << bit) & old_w) >> bit) as i64; // +1 or -1
self.bits[key] = new_w;
}
Expand Down
2 changes: 1 addition & 1 deletion roaring/src/treemap/inherent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ impl RoaringTreemap {
for (&key, bitmap) in &self.map {
let len = bitmap.len();
if len > n {
return Some((key as u64) << 32 | bitmap.select(n as u32).unwrap() as u64);
return Some(((key as u64) << 32) | bitmap.select(n as u32).unwrap() as u64);
}
n -= len;
}
Expand Down

0 comments on commit 4dfd47b

Please sign in to comment.