Skip to content

Refactor/clippy warnings #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 7 additions & 11 deletions src/clangd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -38,17 +38,17 @@ pub struct ClangdMatcher {

use_cache: bool,

c_cache: CachedThreadLocal<RefCell<Vec<char>>>, // vector to store the characters of choice
p_cache: CachedThreadLocal<RefCell<Vec<char>>>, // vector to store the characters of pattern
c_cache: ThreadLocal<RefCell<Vec<char>>>, // vector to store the characters of choice
p_cache: ThreadLocal<RefCell<Vec<char>>>, // vector to store the characters of pattern
}

impl Default for ClangdMatcher {
fn default() -> Self {
Self {
case: CaseMatching::Ignore,
use_cache: true,
c_cache: CachedThreadLocal::new(),
p_cache: CachedThreadLocal::new(),
c_cache: ThreadLocal::new(),
p_cache: ThreadLocal::new(),
}
}
}
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/skim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -945,7 +945,7 @@ impl SkimMatcherV2 {
case_sensitive: bool,
with_pos: bool,
) -> Option<(ScoreType, Vec<IndexType>)> {
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];
Expand Down