Skip to content

Commit

Permalink
Inline the RoaringBitmap max method
Browse files Browse the repository at this point in the history
  • Loading branch information
Kerollmops committed Sep 23, 2024
1 parent d8f1829 commit 6bba84b
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 @@ -161,6 +161,7 @@ impl Container {
self.store.min()
}

#[inline]
pub fn max(&self) -> Option<u16> {
self.store.max()
}
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 @@ -513,6 +513,7 @@ impl RoaringBitmap {
/// rb.insert(4);
/// assert_eq!(rb.max(), Some(4));
/// ```
#[inline]
pub fn max(&self) -> Option<u32> {
self.containers.last().and_then(|tail| tail.max().map(|max| util::join(tail.key, max)))
}
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 @@ -209,6 +209,7 @@ impl ArrayStore {
self.vec.first().copied()
}

#[inline]
pub fn max(&self) -> Option<u16> {
self.vec.last().copied()
}
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 @@ -254,6 +254,7 @@ impl BitmapStore {
.map(|(index, bit)| (index * 64 + (bit.trailing_zeros() as usize)) as u16)
}

#[inline]
pub fn max(&self) -> Option<u16> {
self.bits
.iter()
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 @@ -193,6 +193,7 @@ impl Store {
}
}

#[inline]
pub fn max(&self) -> Option<u16> {
match self {
Array(vec) => vec.max(),
Expand Down

0 comments on commit 6bba84b

Please sign in to comment.