Skip to content

Commit

Permalink
Inline most the insertion functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Kerollmops committed Sep 16, 2024
1 parent 348e58c commit d8f1829
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions roaring/src/bitmap/container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ impl Container {
self.store.is_empty()
}

#[inline]
pub fn insert(&mut self, index: u16) -> bool {
if self.store.insert(index) {
self.ensure_correct_store();
Expand Down
1 change: 1 addition & 0 deletions roaring/src/bitmap/inherent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ impl RoaringBitmap {
/// assert_eq!(rb.insert(3), false);
/// assert_eq!(rb.contains(3), true);
/// ```
#[inline]
pub fn insert(&mut self, value: u32) -> bool {
let (key, index) = util::split(value);
let container = match self.containers.binary_search_by_key(&key, |c| c.key) {
Expand Down
1 change: 1 addition & 0 deletions roaring/src/bitmap/store/array_store/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ impl ArrayStore {
}
}

#[inline]
pub fn insert(&mut self, index: u16) -> bool {
self.vec.binary_search(&index).map_err(|loc| self.vec.insert(loc, index)).is_err()
}
Expand Down
1 change: 1 addition & 0 deletions roaring/src/bitmap/store/bitmap_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ impl BitmapStore {
}
}

#[inline]
pub fn insert(&mut self, index: u16) -> bool {
let (key, bit) = (key(index), bit(index));
let old_w = self.bits[key];
Expand Down
1 change: 1 addition & 0 deletions roaring/src/bitmap/store/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ impl Store {
Store::Bitmap(BitmapStore::full())
}

#[inline]
pub fn insert(&mut self, index: u16) -> bool {
match self {
Array(vec) => vec.insert(index),
Expand Down

0 comments on commit d8f1829

Please sign in to comment.