Skip to content

Commit

Permalink
Merge pull request #54 from Veedrac/issue-53
Browse files Browse the repository at this point in the history
Algorithm failed on big endian machines #53
  • Loading branch information
llogiq authored Feb 10, 2019
2 parents 364ae05 + db2b9ef commit e55b27e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/integer_simd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ pub fn chunk_count(haystack: &[u8], needle: u8) -> usize {
counts += bytewise_equal(usize_load_unchecked(haystack, offset + i * chunksize), needles);
}
if haystack.len() % 8 != 0 {
let mask = !(!0 >> ((haystack.len() % chunksize) * 8));
let mask = usize::from_le(!(!0 >> ((haystack.len() % chunksize) * 8)));
counts += bytewise_equal(usize_load_unchecked(haystack, haystack.len() - chunksize), needles) & mask;
}
count += sum_usize(counts);
Expand Down Expand Up @@ -101,7 +101,7 @@ pub fn chunk_num_chars(utf8_chars: &[u8]) -> usize {
counts += is_leading_utf8_byte(usize_load_unchecked(utf8_chars, offset + i * chunksize));
}
if utf8_chars.len() % 8 != 0 {
let mask = !(!0 >> ((utf8_chars.len() % chunksize) * 8));
let mask = usize::from_le(!(!0 >> ((utf8_chars.len() % chunksize) * 8)));
counts += is_leading_utf8_byte(usize_load_unchecked(utf8_chars, utf8_chars.len() - chunksize)) & mask;
}
count += sum_usize(counts);
Expand Down

0 comments on commit e55b27e

Please sign in to comment.