mirror of
https://github.com/elicpeter/nyx.git
synced 2026-06-27 20:29:39 +02:00
Fixed clippy errors
This commit is contained in:
parent
16b469c16f
commit
f4544d261e
2 changed files with 8 additions and 9 deletions
|
|
@ -1,7 +1,5 @@
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::sync::RwLock;
|
use std::sync::{Arc, LazyLock, RwLock};
|
||||||
|
|
||||||
use once_cell::sync::Lazy;
|
|
||||||
use tree_sitter::{Language, Query};
|
use tree_sitter::{Language, Query};
|
||||||
|
|
||||||
use crate::patterns::{self, Pattern};
|
use crate::patterns::{self, Pattern};
|
||||||
|
|
@ -9,11 +7,12 @@ use crate::patterns::{self, Pattern};
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct CompiledQuery {
|
pub struct CompiledQuery {
|
||||||
pub meta: Pattern,
|
pub meta: Pattern,
|
||||||
pub query: std::sync::Arc<Query>,
|
pub query: Arc<Query>,
|
||||||
}
|
}
|
||||||
|
|
||||||
static CACHE: Lazy<RwLock<HashMap<&'static str, std::sync::Arc<Vec<CompiledQuery>>>>> =
|
type QuerySet = Arc<Vec<CompiledQuery>>;
|
||||||
Lazy::new(|| RwLock::new(HashMap::new()));
|
static CACHE: LazyLock<RwLock<HashMap<&'static str, QuerySet>>> =
|
||||||
|
LazyLock::new(|| RwLock::new(HashMap::new()));
|
||||||
|
|
||||||
/// Return **one shared Arc** to the per-language query set.
|
/// Return **one shared Arc** to the per-language query set.
|
||||||
/// Cloning the `Arc` is O(1) and the underlying Vec lives for the
|
/// Cloning the `Arc` is O(1) and the underlying Vec lives for the
|
||||||
|
|
@ -37,7 +36,7 @@ pub fn for_lang(lang: &'static str, ts_lang: Language) -> std::sync::Arc<Vec<Com
|
||||||
}).collect();
|
}).collect();
|
||||||
|
|
||||||
let compiled = std::sync::Arc::new(compiled);
|
let compiled = std::sync::Arc::new(compiled);
|
||||||
|
|
||||||
let mut w = CACHE.write().unwrap();
|
let mut w = CACHE.write().unwrap();
|
||||||
w.entry(lang).or_insert_with(|| compiled.clone()).clone()
|
w.entry(lang).or_insert_with(|| compiled.clone()).clone()
|
||||||
}
|
}
|
||||||
|
|
@ -61,7 +61,7 @@ pub fn spawn_senders(root: &Path, cfg: &Config) -> Receiver<Batch> {
|
||||||
let root = root.to_path_buf();
|
let root = root.to_path_buf();
|
||||||
let scan_hidden = cfg.scanner.scan_hidden_files;
|
let scan_hidden = cfg.scanner.scan_hidden_files;
|
||||||
let follow = cfg.scanner.follow_symlinks;
|
let follow = cfg.scanner.follow_symlinks;
|
||||||
let max_bytes = cfg.scanner.max_file_size_mb.unwrap_or(0) as u64 * 1_048_576;
|
let max_bytes = cfg.scanner.max_file_size_mb.unwrap_or(0) * 1_048_576;
|
||||||
|
|
||||||
// ----- 3 the background walker thread ---------------------------------
|
// ----- 3 the background walker thread ---------------------------------
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
|
|
@ -94,7 +94,7 @@ pub fn spawn_senders(root: &Path, cfg: &Config) -> Receiver<Batch> {
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tracing::debug!("sending {:?}", entry);
|
tracing::debug!("sending {:?}", entry);
|
||||||
b.push(entry.into_path());
|
b.push(entry.into_path());
|
||||||
WalkState::Continue
|
WalkState::Continue
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue