Skip to content

Commit

Permalink
refactor(rust): Minor CSV bit twiddle nitpick
Browse files Browse the repository at this point in the history
  • Loading branch information
orlp committed Oct 7, 2024
1 parent 018dfd1 commit 5e4162f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions crates/polars-io/src/csv/read/splitfields.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,10 @@ mod inner {
.unwrap_unchecked_release()
};
let simd_bytes = SimdVec::from(lane);
let eol_mask = simd_bytes.simd_eq(self.simd_eol_char).to_bitmask();
let sep_mask = simd_bytes.simd_eq(self.simd_separator).to_bitmask();
let has_eol = simd_bytes.simd_eq(self.simd_eol_char);
let has_sep = simd_bytes.simd_eq(self.simd_separator);
let quote_mask = simd_bytes.simd_eq(self.simd_quote_char).to_bitmask();
let mut end_mask = sep_mask | eol_mask;
let mut end_mask = (has_sep | has_eol).to_bitmask();

let mut not_in_quote_field = prefix_xorsum_inclusive(quote_mask);

Expand Down Expand Up @@ -360,12 +360,12 @@ mod inner {
.unwrap_unchecked_release()
};
let simd_bytes = SimdVec::from(lane);
let has_eol_char = simd_bytes.simd_eq(self.simd_eol_char).to_bitmask();
let has_separator = simd_bytes.simd_eq(self.simd_separator).to_bitmask();
let has_any = has_separator | has_eol_char;
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_mask = (has_separator | has_eol_char).to_bitmask();

if has_any != 0 {
total_idx += has_any.trailing_zeros() as usize;
if has_any_mask != 0 {
total_idx += has_any_mask.trailing_zeros() as usize;
break;
} else {
total_idx += SIMD_SIZE;
Expand Down
4 changes: 2 additions & 2 deletions crates/polars-utils/src/clmul.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub fn portable_prefix_xorsum(x: u64) -> u64 {
portable_prefix_xorsum_inclusive(x << 1)
}

// Computes for each bit i the XOR of all less significant bits.
// Computes for each bit i the XOR of bits[0..i].
#[inline]
pub fn prefix_xorsum(x: u64) -> u64 {
#[cfg(all(target_arch = "x86_64", target_feature = "pclmulqdq"))]
Expand All @@ -82,7 +82,7 @@ pub fn portable_prefix_xorsum_inclusive(mut x: u64) -> u64 {
x
}

// Computes for each bit i the XOR of all less significant bits.
// Computes for each bit i the XOR of bits[0..=i].
#[inline]
pub fn prefix_xorsum_inclusive(x: u64) -> u64 {
#[cfg(all(target_arch = "x86_64", target_feature = "pclmulqdq"))]
Expand Down

0 comments on commit 5e4162f

Please sign in to comment.