summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Gallant <jamslam@gmail.com>2019-02-09 16:07:51 -0500
committerAndrew Gallant <jamslam@gmail.com>2019-02-09 16:13:07 -0500
commita4868b88351318182eed3b801d0c97a106a7d38f (patch)
tree3a3f6a078de597d0817667112b14a6fa5f8fee81
parentf99b991117f4a2f26a28946c81c459b595b4d65e (diff)
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
-rw-r--r--grep-searcher/src/lines.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/grep-searcher/src/lines.rs b/grep-searcher/src/lines.rs
index ed225a42..9393234c 100644
--- a/grep-searcher/src/lines.rs
+++ b/grep-searcher/src/lines.rs
@@ -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)]