Skip to content

Commit

Permalink
replace checked_add(sub).unwrap() with +(-)
Browse files Browse the repository at this point in the history
Signed-off-by: remzi <13716567376yh@gmail.com>
  • Loading branch information
HaoYang670 committed Jun 23, 2022
1 parent fc4044f commit 4c118b3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
6 changes: 3 additions & 3 deletions arrow/src/array/array_binary.rs
Expand Up @@ -459,7 +459,7 @@ impl FixedSizeBinaryArray {
i < self.data.len(),
"FixedSizeBinaryArray out of bounds access"
);
let offset = i.checked_add(self.data.offset()).unwrap();
let offset = i + self.data.offset();
unsafe {
let pos = self.value_offset_at(offset);
std::slice::from_raw_parts(
Expand All @@ -473,7 +473,7 @@ impl FixedSizeBinaryArray {
/// # Safety
/// Caller is responsible for ensuring that the index is within the bounds of the array
pub unsafe fn value_unchecked(&self, i: usize) -> &[u8] {
let offset = i.checked_add(self.data.offset()).unwrap();
let offset = i + self.data.offset();
let pos = self.value_offset_at(offset);
std::slice::from_raw_parts(
self.value_data.as_ptr().offset(pos as isize),
Expand Down Expand Up @@ -779,7 +779,7 @@ impl DecimalArray {
/// Returns the element at index `i`.
pub fn value(&self, i: usize) -> Decimal128 {
assert!(i < self.data.len(), "DecimalArray out of bounds access");
let offset = i.checked_add(self.data.offset()).unwrap();
let offset = i + self.data.offset();
let raw_val = unsafe {
let pos = self.value_offset_at(offset);
std::slice::from_raw_parts(
Expand Down
3 changes: 1 addition & 2 deletions arrow/src/array/data.rs
Expand Up @@ -40,8 +40,7 @@ pub(crate) fn count_nulls(
len: usize,
) -> usize {
if let Some(buf) = null_bit_buffer {
len.checked_sub(buf.count_set_bits_offset(offset, len))
.unwrap()
len - buf.count_set_bits_offset(offset, len)
} else {
0
}
Expand Down

0 comments on commit 4c118b3

Please sign in to comment.