1
0
mirror of https://github.com/BurntSushi/ripgrep.git synced 2025-03-03 14:32:22 +02:00

searcher: use naive line counting on big-endian

This patches out bytecount's "fast" vectorized algorithm on big-endian
machines, where it has been observed to fail. Going forward, bytecount
should probably fix this on their end, but for now, we take a small
performance hit on big-endian machines.

Fixes #1144
This commit is contained in:
Andrew Gallant 2019-02-09 16:07:51 -05:00
parent f99b991117
commit a4868b8835
No known key found for this signature in database
GPG Key ID: B2E3A4923F8B0D44

View File

@ -109,10 +109,17 @@ impl LineStep {
}
/// Count the number of occurrences of `line_term` in `bytes`.
#[cfg(target_endian = "little")]
pub fn count(bytes: &[u8], line_term: u8) -> u64 {
bytecount::count(bytes, line_term) as u64
}
/// Count the number of occurrences of `line_term` in `bytes`.
#[cfg(target_endian = "big")]
pub fn count(bytes: &[u8], line_term: u8) -> u64 {
bytecount::naive_count(bytes, line_term) as u64
}
/// Given a line that possibly ends with a terminator, return that line without
/// the terminator.
#[inline(always)]