summaryrefslogtreecommitdiffstats
path: root/grep-matcher/src/interpolate.rs
diff options
context:
space:
mode:
authorAndrew Gallant <jamslam@gmail.com>2019-01-20 12:32:09 -0500
committerAndrew Gallant <jamslam@gmail.com>2019-01-20 12:32:09 -0500
commit4b88e08f418d4c24223879a727efa5ad0c3c9058 (patch)
tree213f92d921b28d3d1841742085810005b9cf7bfd /grep-matcher/src/interpolate.rs
parent7cbc535d70a53c81dfa3e58552c01f21c2e38d28 (diff)
search: migrate to bstrag/bstr-migration
This is an initial attempt at migrating grep-searcher to use the new bstr crate (not yet published). This is mostly an improvement, although a significant problem is that the grep-matcher crate controls the `Index` impls for the `Match` type, which we use quite heavily. Thus, in order to impl `Index` for `BStr`, we need add bstr as a public dependency to grep-matcher. This is really bad news because grep-matcher is supposed to be a light-weight core crate that defines a matcher interface, which is itself intended to be a public dependency. Thus, a semver bump on bstr will have very undesirable ripple effects thoughout ripgrep's library crates. This would be something we could stomach if bstr was solid at 1.0 and committed to avoiding breaking changes. But it's not there yet.
Diffstat (limited to 'grep-matcher/src/interpolate.rs')
-rw-r--r--grep-matcher/src/interpolate.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/grep-matcher/src/interpolate.rs b/grep-matcher/src/interpolate.rs
index 168dd343..126ce521 100644
--- a/grep-matcher/src/interpolate.rs
+++ b/grep-matcher/src/interpolate.rs
@@ -1,6 +1,6 @@
use std::str;
-use memchr::memchr;
+use bstr::B;
/// Interpolate capture references in `replacement` and write the interpolation
/// result to `dst`. References in `replacement` take the form of $N or $name,
@@ -22,7 +22,7 @@ pub fn interpolate<A, N>(
N: FnMut(&str) -> Option<usize>
{
while !replacement.is_empty() {
- match memchr(b'$', replacement) {
+ match B(replacement).find_byte(b'$') {
None => break,
Some(i) => {
dst.extend(&replacement[..i]);