1
0
mirror of https://github.com/BurntSushi/ripgrep.git synced 2025-04-14 00:58:43 +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
No known key found for this signature in database
GPG Key ID: B2E3A4923F8B0D44
3 changed files with 16 additions and 10 deletions

12
Cargo.lock generated
View File

@ -369,6 +369,12 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "once_cell"
version = "1.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "13bd41f508810a131401606d54ac32a467c97172d74ba7662562ebba5ad07fa0"
[[package]] [[package]]
name = "packed_simd_2" name = "packed_simd_2"
version = "0.3.4" version = "0.3.4"
@ -553,11 +559,11 @@ dependencies = [
[[package]] [[package]]
name = "thread_local" name = "thread_local"
version = "1.1.0" version = "1.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb9bc092d0d51e76b2b19d9d85534ffc9ec2db959a2523cdae0697e2972cd447" checksum = "d8208a331e1cb318dd5bd76951d2b8fc48ca38a69f5f4e4af1b6a9f8c6236915"
dependencies = [ dependencies = [
"lazy_static", "once_cell",
] ]
[[package]] [[package]]

View File

@ -19,4 +19,4 @@ grep-matcher = { version = "0.1.2", path = "../matcher" }
log = "0.4.5" log = "0.4.5"
regex = "1.1" regex = "1.1"
regex-syntax = "0.6.5" regex-syntax = "0.6.5"
thread_local = "1" thread_local = "1.1.2"

View File

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