From d8f1829dde90a29bb72e354ae0780871d09635c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Mon, 16 Sep 2024 15:15:59 +0200 Subject: [PATCH] Inline most the insertion functions --- 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 b72965c5..4017eaab 100644 --- a/roaring/src/bitmap/container.rs +++ b/roaring/src/bitmap/container.rs @@ -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(); diff --git a/roaring/src/bitmap/inherent.rs b/roaring/src/bitmap/inherent.rs index 559b7579..b2919b4c 100644 --- a/roaring/src/bitmap/inherent.rs +++ b/roaring/src/bitmap/inherent.rs @@ -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) { diff --git a/roaring/src/bitmap/store/array_store/mod.rs b/roaring/src/bitmap/store/array_store/mod.rs index 883db31f..e252caba 100644 --- a/roaring/src/bitmap/store/array_store/mod.rs +++ b/roaring/src/bitmap/store/array_store/mod.rs @@ -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() } diff --git a/roaring/src/bitmap/store/bitmap_store.rs b/roaring/src/bitmap/store/bitmap_store.rs index 14a97cc7..7a181e3f 100644 --- a/roaring/src/bitmap/store/bitmap_store.rs +++ b/roaring/src/bitmap/store/bitmap_store.rs @@ -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]; diff --git a/roaring/src/bitmap/store/mod.rs b/roaring/src/bitmap/store/mod.rs index 71d981a2..bc46c532 100644 --- a/roaring/src/bitmap/store/mod.rs +++ b/roaring/src/bitmap/store/mod.rs @@ -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),