Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MINOR: Replace checked_add/sub().unwrap() with +/- #1924

Merged
merged 1 commit into from Jun 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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