From 6bba84b1a47da1d6e52d5c4dc0ce8593ae4646a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Mon, 23 Sep 2024 16:52:15 +0200 Subject: [PATCH] Inline the RoaringBitmap max method --- roaring/src/bitmap/container.rs | 1 + roaring/src/bitmap/inherent.rs | 1 + roaring/src/bitmap/store/array_store/mod.rs | 1 + roaring/src/bitmap/store/bitmap_store.rs | 1 + roaring/src/bitmap/store/mod.rs | 1 + 5 files changed, 5 insertions(+) diff --git a/roaring/src/bitmap/container.rs b/roaring/src/bitmap/container.rs index 4017eaab..bdceef0e 100644 --- a/roaring/src/bitmap/container.rs +++ b/roaring/src/bitmap/container.rs @@ -161,6 +161,7 @@ impl Container { self.store.min() } + #[inline] pub fn max(&self) -> Option { self.store.max() } diff --git a/roaring/src/bitmap/inherent.rs b/roaring/src/bitmap/inherent.rs index b2919b4c..a781cea5 100644 --- a/roaring/src/bitmap/inherent.rs +++ b/roaring/src/bitmap/inherent.rs @@ -513,6 +513,7 @@ impl RoaringBitmap { /// rb.insert(4); /// assert_eq!(rb.max(), Some(4)); /// ``` + #[inline] pub fn max(&self) -> Option { self.containers.last().and_then(|tail| tail.max().map(|max| util::join(tail.key, max))) } diff --git a/roaring/src/bitmap/store/array_store/mod.rs b/roaring/src/bitmap/store/array_store/mod.rs index e252caba..0cfa5ad5 100644 --- a/roaring/src/bitmap/store/array_store/mod.rs +++ b/roaring/src/bitmap/store/array_store/mod.rs @@ -209,6 +209,7 @@ impl ArrayStore { self.vec.first().copied() } + #[inline] pub fn max(&self) -> Option { self.vec.last().copied() } diff --git a/roaring/src/bitmap/store/bitmap_store.rs b/roaring/src/bitmap/store/bitmap_store.rs index 7a181e3f..a555f86c 100644 --- a/roaring/src/bitmap/store/bitmap_store.rs +++ b/roaring/src/bitmap/store/bitmap_store.rs @@ -254,6 +254,7 @@ impl BitmapStore { .map(|(index, bit)| (index * 64 + (bit.trailing_zeros() as usize)) as u16) } + #[inline] pub fn max(&self) -> Option { self.bits .iter() diff --git a/roaring/src/bitmap/store/mod.rs b/roaring/src/bitmap/store/mod.rs index bc46c532..d6639e9c 100644 --- a/roaring/src/bitmap/store/mod.rs +++ b/roaring/src/bitmap/store/mod.rs @@ -193,6 +193,7 @@ impl Store { } } + #[inline] pub fn max(&self) -> Option { match self { Array(vec) => vec.max(),