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

regex: s/CachedThreadLocal/ThreadLocal

CachedThreadLocal has been deprecated. We bump thread_local's minimal
version corresponding to that deprecation as well.
This commit is contained in:
Andrew Gallant
2021-01-25 10:36:53 -05:00
parent ae55a4e872
commit 7899a4b931
3 changed files with 16 additions and 10 deletions

View File

@ -4,7 +4,7 @@ use std::sync::Arc;
use grep_matcher::{Match, Matcher, NoError};
use regex::bytes::{CaptureLocations, Regex};
use thread_local::CachedThreadLocal;
use thread_local::ThreadLocal;
use config::ConfiguredHIR;
use error::Error;
@ -21,19 +21,19 @@ pub struct WordMatcher {
/// A map from capture group name to capture group index.
names: HashMap<String, usize>,
/// A reusable buffer for finding the match location of the inner group.
locs: Arc<CachedThreadLocal<RefCell<CaptureLocations>>>,
locs: Arc<ThreadLocal<RefCell<CaptureLocations>>>,
}
impl Clone for WordMatcher {
fn clone(&self) -> WordMatcher {
// We implement Clone manually so that we get a fresh CachedThreadLocal
// such that it can set its own thread owner. This permits each thread
// We implement Clone manually so that we get a fresh ThreadLocal such
// that it can set its own thread owner. This permits each thread
// usings `locs` to hit the fast path.
WordMatcher {
regex: self.regex.clone(),
original: self.original.clone(),
names: self.names.clone(),
locs: Arc::new(CachedThreadLocal::new()),
locs: Arc::new(ThreadLocal::new()),
}
}
}
@ -53,7 +53,7 @@ impl WordMatcher {
pat
})?;
let regex = word_expr.regex()?;
let locs = Arc::new(CachedThreadLocal::new());
let locs = Arc::new(ThreadLocal::new());
let mut names = HashMap::new();
for (i, optional_name) in regex.capture_names().enumerate() {