From 8e7554b7cd79ee1297e381e847bd715a004f715a Mon Sep 17 00:00:00 2001 From: Simon Lin Date: Fri, 11 Oct 2024 15:36:07 +1100 Subject: [PATCH] c --- crates/polars-arrow/src/bitmap/immutable.rs | 7 ++----- crates/polars-arrow/src/bitmap/mutable.rs | 9 +++------ 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/crates/polars-arrow/src/bitmap/immutable.rs b/crates/polars-arrow/src/bitmap/immutable.rs index a475b0b7845f..2ba89e68568a 100644 --- a/crates/polars-arrow/src/bitmap/immutable.rs +++ b/crates/polars-arrow/src/bitmap/immutable.rs @@ -344,11 +344,8 @@ impl Bitmap { /// Unsound iff `i >= self.len()`. #[inline] pub unsafe fn get_bit_unchecked(&self, i: usize) -> bool { - if cfg!(debug_assertions) { - self.get_bit(i) - } else { - get_bit_unchecked(&self.storage, self.offset + i) - } + debug_assert!(i < self.len()); + get_bit_unchecked(&self.storage, self.offset + i) } /// Returns a pointer to the start of this [`Bitmap`] (ignores `offsets`) diff --git a/crates/polars-arrow/src/bitmap/mutable.rs b/crates/polars-arrow/src/bitmap/mutable.rs index 6ca6a2aaded0..05bbbe5dd976 100644 --- a/crates/polars-arrow/src/bitmap/mutable.rs +++ b/crates/polars-arrow/src/bitmap/mutable.rs @@ -362,12 +362,9 @@ impl MutableBitmap { /// Caller must ensure that `index < self.len()` #[inline] pub unsafe fn set_unchecked(&mut self, index: usize, value: bool) { - if cfg!(debug_assertions) { - self.set(index, value) - } else { - let byte = self.buffer.get_unchecked_mut(index / 8); - *byte = set_bit_in_byte(*byte, index % 8, value); - } + debug_assert!(index < self.len()); + let byte = self.buffer.get_unchecked_mut(index / 8); + *byte = set_bit_in_byte(*byte, index % 8, value); } /// Shrinks the capacity of the [`MutableBitmap`] to fit its current length.