perf: use rustc-hash for HashMap and HashSet
Since we already depend on `rustc-hash` transiently, this doesn't add any more dependencies. As long as DOS attacks aren't a concern (which I don't think they are?), this should be free performance. In my (admittedly naive) testing, this really improved CPU usage in some cases, which is pretty nice to get for free.
This commit is contained in:
parent
4be92ae8ca
commit
43a9fca4ec
11 changed files with 68 additions and 68 deletions
|
|
@ -5,9 +5,9 @@
|
|||
use cosmic::desktop;
|
||||
use cosmic::widget;
|
||||
pub use mime_guess::Mime;
|
||||
use rustc_hash::FxHashMap;
|
||||
use std::{
|
||||
cmp::Ordering,
|
||||
collections::HashMap,
|
||||
env,
|
||||
ffi::OsStr,
|
||||
fs, io,
|
||||
|
|
@ -221,8 +221,8 @@ fn filename_eq(path_opt: &Option<PathBuf>, filename: &str) -> bool {
|
|||
|
||||
pub struct MimeAppCache {
|
||||
apps: Vec<MimeApp>,
|
||||
cache: HashMap<Mime, Vec<MimeApp>>,
|
||||
icons: HashMap<Mime, Vec<widget::icon::Handle>>,
|
||||
cache: FxHashMap<Mime, Vec<MimeApp>>,
|
||||
icons: FxHashMap<Mime, Vec<widget::icon::Handle>>,
|
||||
terminals: Vec<MimeApp>,
|
||||
}
|
||||
|
||||
|
|
@ -230,8 +230,8 @@ impl MimeAppCache {
|
|||
pub fn new() -> Self {
|
||||
let mut mime_app_cache = Self {
|
||||
apps: Vec::new(),
|
||||
cache: HashMap::new(),
|
||||
icons: HashMap::new(),
|
||||
cache: FxHashMap::default(),
|
||||
icons: FxHashMap::default(),
|
||||
terminals: Vec::new(),
|
||||
};
|
||||
mime_app_cache.reload();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue