treewide: replace std hashers with rustc_hash alternatives; fix clippy

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I766c36cb53d3d7f9e85b91a67c4131a66a6a6964
This commit is contained in:
raf 2026-03-19 22:34:30 +03:00
commit f831e58723
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF
53 changed files with 343 additions and 394 deletions

View file

@ -13,12 +13,12 @@
//! priority 100. A circuit breaker disables plugins after consecutive failures.
use std::{
collections::HashMap,
path::{Path, PathBuf},
sync::Arc,
time::{Duration, Instant},
};
use rustc_hash::FxHashMap;
use tokio::sync::RwLock;
use tracing::{debug, info, warn};
@ -75,22 +75,22 @@ struct CachedCapabilities {
/// Keyed by `(kind, plugin_id)` -> list of supported type strings.
/// Separate entries for each kind avoid collisions when a plugin
/// implements both `metadata_extractor` and `thumbnail_generator`.
supported_types: HashMap<(String, String), Vec<String>>,
supported_types: FxHashMap<(String, String), Vec<String>>,
/// `plugin_id` -> list of interested event type strings
interested_events: HashMap<String, Vec<String>>,
interested_events: FxHashMap<String, Vec<String>>,
/// `plugin_id` -> list of media type definitions (for `MediaTypeProvider`)
media_type_definitions: HashMap<String, Vec<PluginMediaTypeDefinition>>,
media_type_definitions: FxHashMap<String, Vec<PluginMediaTypeDefinition>>,
/// `plugin_id` -> list of theme definitions (for `ThemeProvider`)
theme_definitions: HashMap<String, Vec<PluginThemeDefinition>>,
theme_definitions: FxHashMap<String, Vec<PluginThemeDefinition>>,
}
impl CachedCapabilities {
fn new() -> Self {
Self {
supported_types: HashMap::new(),
interested_events: HashMap::new(),
media_type_definitions: HashMap::new(),
theme_definitions: HashMap::new(),
supported_types: FxHashMap::default(),
interested_events: FxHashMap::default(),
media_type_definitions: FxHashMap::default(),
theme_definitions: FxHashMap::default(),
}
}
}
@ -101,7 +101,7 @@ pub struct PluginPipeline {
manager: Arc<PluginManager>,
timeouts: PluginTimeoutConfig,
max_consecutive_failures: u32,
health: RwLock<HashMap<String, PluginHealth>>,
health: RwLock<FxHashMap<String, PluginHealth>>,
capabilities: RwLock<CachedCapabilities>,
}
@ -117,7 +117,7 @@ impl PluginPipeline {
manager,
timeouts,
max_consecutive_failures,
health: RwLock::new(HashMap::new()),
health: RwLock::new(FxHashMap::default()),
capabilities: RwLock::new(CachedCapabilities::new()),
}
}
@ -826,7 +826,7 @@ impl PluginPipeline {
}
// Deduplicate by ID, keeping the highest-scoring entry
let mut seen: HashMap<String, usize> = HashMap::new();
let mut seen: FxHashMap<String, usize> = FxHashMap::default();
let mut deduped: Vec<SearchResultItem> = Vec::new();
for item in all_results {
if let Some(&idx) = seen.get(&item.id) {
@ -1363,7 +1363,7 @@ mod tests {
year: Some(2024),
duration_secs: None,
description: None,
extra: HashMap::new(),
extra: FxHashMap::default(),
};
merge_metadata(&mut base, &resp);
@ -1379,7 +1379,7 @@ mod tests {
let mut base = ExtractedMetadata::default();
base.extra.insert("key1".to_string(), "val1".to_string());
let mut extra = HashMap::new();
let mut extra = FxHashMap::default();
extra.insert("key2".to_string(), "val2".to_string());
extra.insert("key1".to_string(), "overwritten".to_string());