diff --git a/roaring/src/bitmap/iter.rs b/roaring/src/bitmap/iter.rs index b6e16f81..23c9f37e 100644 --- a/roaring/src/bitmap/iter.rs +++ b/roaring/src/bitmap/iter.rs @@ -732,6 +732,7 @@ impl Extend for RoaringBitmap { /// assert!(rb.contains(1508)); /// assert!(!rb.contains(5)); /// ``` + #[inline] fn extend>(&mut self, values: I) { let mut values = values.into_iter(); let value = match values.next() { @@ -742,18 +743,18 @@ impl Extend 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); } } } @@ -777,6 +778,7 @@ impl<'a> Extend<&'a u32> for RoaringBitmap { /// assert!(rb.contains(1508)); /// assert!(!rb.contains(5)); /// ``` + #[inline] fn extend>(&mut self, values: I) { self.extend(values.into_iter().copied()); } diff --git a/roaring/src/bitmap/store/bitmap_store.rs b/roaring/src/bitmap/store/bitmap_store.rs index cf4649c1..aec2404a 100644 --- a/roaring/src/bitmap/store/bitmap_store.rs +++ b/roaring/src/bitmap/store/bitmap_store.rs @@ -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; @@ -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; } @@ -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; } diff --git a/roaring/src/treemap/inherent.rs b/roaring/src/treemap/inherent.rs index 9db01ebf..63e2cb3b 100644 --- a/roaring/src/treemap/inherent.rs +++ b/roaring/src/treemap/inherent.rs @@ -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; }