Skip to content

Commit

Permalink
refactor(rust): Fencepost error in debug assertion in splitfields (#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
wence- authored Aug 28, 2024
1 parent 20ce0f1 commit 37a492e
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions crates/polars-io/src/csv/read/splitfields.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,21 +266,21 @@ mod inner {
let bytes = unsafe { self.v.get_unchecked_release(total_idx..) };

if bytes.len() > SIMD_SIZE {
unsafe {
let lane: [u8; SIMD_SIZE] = bytes
let lane: [u8; SIMD_SIZE] = unsafe {
bytes
.get_unchecked(0..SIMD_SIZE)
.try_into()
.unwrap_unchecked_release();
let simd_bytes = SimdVec::from(lane);
let has_eol_char = simd_bytes.simd_eq(self.simd_eol_char);
let has_separator = simd_bytes.simd_eq(self.simd_separator);
let has_any = has_separator.bitor(has_eol_char);
if let Some(idx) = has_any.first_set() {
total_idx += idx;
break;
} else {
total_idx += SIMD_SIZE;
}
.unwrap_unchecked_release()
};
let simd_bytes = SimdVec::from(lane);
let has_eol_char = simd_bytes.simd_eq(self.simd_eol_char);
let has_separator = simd_bytes.simd_eq(self.simd_separator);
let has_any = has_separator.bitor(has_eol_char);
if let Some(idx) = has_any.first_set() {
total_idx += idx;
break;
} else {
total_idx += SIMD_SIZE;
}
} else {
match bytes.iter().position(|&c| self.eof_oel(c)) {
Expand All @@ -302,7 +302,7 @@ mod inner {
};

unsafe {
debug_assert!(pos <= self.v.len());
debug_assert!(pos < self.v.len());
// SAFETY:
// we are in bounds
let ret = Some((self.v.get_unchecked(..pos), needs_escaping));
Expand Down

0 comments on commit 37a492e

Please sign in to comment.