Skip to content

Commit

Permalink
first branch cache check
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 committed Oct 5, 2024
1 parent 1a1d3ab commit aa2382e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
13 changes: 7 additions & 6 deletions crates/polars-io/src/csv/read/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,12 +438,7 @@ impl<'a> Iterator for SplitLines<'a> {
#[inline]
#[cfg(feature = "simd")]
fn next(&mut self) -> Option<&'a [u8]> {
if self.v.is_empty() {
return None;
}
self.total_index = 0;
let mut not_in_field_previous_iter = true;

// First check cached value
if self.previous_valid_eols != 0 {
let pos = self.previous_valid_eols.trailing_zeros() as usize;
self.previous_valid_eols >>= (pos + 1) as u64;
Expand All @@ -458,6 +453,12 @@ impl<'a> Iterator for SplitLines<'a> {
return ret;
}
}
if self.v.is_empty() {
return None;
}

self.total_index = 0;
let mut not_in_field_previous_iter = true;

loop {
let bytes = unsafe { self.v.get_unchecked_release(self.total_index..) };
Expand Down
13 changes: 7 additions & 6 deletions crates/polars-io/src/csv/read/splitfields.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,7 @@ mod inner {

#[inline]
fn next(&mut self) -> Option<(&'a [u8], bool)> {
if self.finished {
return None;
}
if self.v.is_empty() {
return self.finish(false);
}
// First check cached value as this is hot.
if self.previous_valid_ends != 0 {
let pos = self.previous_valid_ends.trailing_zeros() as usize;
self.previous_valid_ends >>= (pos + 1) as u64;
Expand All @@ -241,6 +236,12 @@ mod inner {
return ret;
}
}
if self.finished {
return None;
}
if self.v.is_empty() {
return self.finish(false);
}

let mut needs_escaping = false;
// There can be strings with separators:
Expand Down

0 comments on commit aa2382e

Please sign in to comment.