diff --git a/src/clangd.rs b/src/clangd.rs index 03c2e76..f2037a6 100644 --- a/src/clangd.rs +++ b/src/clangd.rs @@ -24,7 +24,7 @@ use crate::util::*; use crate::{FuzzyMatcher, IndexType, ScoreType}; use std::cell::RefCell; use std::cmp::max; -use thread_local::CachedThreadLocal; +use thread_local::ThreadLocal; #[derive(Eq, PartialEq, Debug, Copy, Clone)] enum CaseMatching { @@ -38,8 +38,8 @@ pub struct ClangdMatcher { use_cache: bool, - c_cache: CachedThreadLocal>>, // vector to store the characters of choice - p_cache: CachedThreadLocal>>, // vector to store the characters of pattern + c_cache: ThreadLocal>>, // vector to store the characters of choice + p_cache: ThreadLocal>>, // vector to store the characters of pattern } impl Default for ClangdMatcher { @@ -47,8 +47,8 @@ impl Default for ClangdMatcher { Self { case: CaseMatching::Ignore, use_cache: true, - c_cache: CachedThreadLocal::new(), - p_cache: CachedThreadLocal::new(), + c_cache: ThreadLocal::new(), + p_cache: ThreadLocal::new(), } } } @@ -116,9 +116,7 @@ impl FuzzyMatcher for ClangdMatcher { pattern_chars.push(char); } - if cheap_matches(&choice_chars, &pattern_chars, case_sensitive).is_none() { - return None; - } + cheap_matches(&choice_chars, &pattern_chars, case_sensitive)?; let num_pattern_chars = pattern_chars.len(); let num_choice_chars = choice_chars.len(); @@ -186,9 +184,7 @@ impl FuzzyMatcher for ClangdMatcher { pattern_chars.push(char); } - if cheap_matches(&choice_chars, &pattern_chars, case_sensitive).is_none() { - return None; - } + cheap_matches(&choice_chars, &pattern_chars, case_sensitive)?; let num_pattern_chars = pattern_chars.len(); let num_choice_chars = choice_chars.len(); diff --git a/src/skim.rs b/src/skim.rs index 107d7e2..dde032e 100644 --- a/src/skim.rs +++ b/src/skim.rs @@ -945,7 +945,7 @@ impl SkimMatcherV2 { case_sensitive: bool, with_pos: bool, ) -> Option<(ScoreType, Vec)> { - if pattern.len() <= 0 { + if pattern.is_empty() { return Some((0, Vec::new())); } else if pattern.len() == 1 { let match_idx = first_match_indices[0];