mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-22 01:57:41 +08:00
Do not check before pushing in bitmaps
This commit is contained in:
parent
ff931edb55
commit
4ce5d3d66d
@ -198,30 +198,29 @@ impl DelAddRoaringBitmap {
|
||||
|
||||
#[derive(Debug, Clone, Default)]
|
||||
struct PushOptimizedBitmap {
|
||||
max: Option<u32>,
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user