Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Commit

Permalink
small null_count optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 committed Sep 23, 2021
1 parent 688e979 commit 91bd01d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/bitmap/immutable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,16 @@ impl Bitmap {
#[inline]
pub fn slice(mut self, offset: usize, length: usize) -> Self {
assert!(offset + length <= self.length);
// count the smallest chunk
if length < self.length / 2 {
// count the null values in the slice
self.null_count = count_zeros(&self.bytes, offset, length);
} else {
// subtract the null count of the chunk we slice off
self.null_count -= count_zeros(&self.bytes, self.offset, self.offset + offset)
}
self.offset += offset;
self.length = length;
self.null_count = count_zeros(&self.bytes, self.offset, self.length);
self
}

Expand Down

0 comments on commit 91bd01d

Please sign in to comment.