From 4ce5d3d66d202559d489483790375a7b05291eac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Tue, 24 Sep 2024 09:42:21 +0200 Subject: [PATCH] Do not check before pushing in bitmaps --- milli/src/update/new/extract/cache.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/milli/src/update/new/extract/cache.rs b/milli/src/update/new/extract/cache.rs index 5e90b1c79..00b4dc46d 100644 --- a/milli/src/update/new/extract/cache.rs +++ b/milli/src/update/new/extract/cache.rs @@ -198,30 +198,29 @@ impl DelAddRoaringBitmap { #[derive(Debug, Clone, Default)] struct PushOptimizedBitmap { - max: Option, bitmap: RoaringBitmap, } impl PushOptimizedBitmap { + #[inline] fn from_bitmap(bitmap: RoaringBitmap) -> PushOptimizedBitmap { - PushOptimizedBitmap { max: bitmap.max(), bitmap } + PushOptimizedBitmap { bitmap } } + #[inline] fn from_single(single: u32) -> PushOptimizedBitmap { - PushOptimizedBitmap { max: Some(single), bitmap: RoaringBitmap::from([single]) } + PushOptimizedBitmap { bitmap: RoaringBitmap::from([single]) } } + #[inline] fn insert(&mut self, n: u32) { - if self.max.map_or(true, |max| n > max) { - self.max = Some(n); - self.bitmap.push(n); - } else { + if !self.bitmap.push(n) { self.bitmap.insert(n); } } + #[inline] fn union_with_bitmap(&mut self, bitmap: RoaringBitmap) { self.bitmap |= bitmap; - self.max = self.bitmap.max(); } }