perf: general minor performance optimisations
Notably there is some code cleanup with the zooming functionality, I've created a new module to reduce code duplication.
This commit is contained in:
parent
5f729829d7
commit
bd1fa1f0a9
16 changed files with 971 additions and 1109 deletions
|
|
@ -80,30 +80,32 @@ impl ThumbnailerCache {
|
|||
let mut search_dirs = Vec::new();
|
||||
let xdg_dirs = xdg::BaseDirectories::new();
|
||||
|
||||
if let Some(data_home) = xdg_dirs.get_data_home() {
|
||||
search_dirs.push(data_home.join("thumbnailers"));
|
||||
}
|
||||
for data_dir in xdg_dirs.get_data_dirs() {
|
||||
search_dirs.push(data_dir.join("thumbnailers"));
|
||||
if let Some(mut data_home) = xdg_dirs.get_data_home() {
|
||||
data_home.push("thumbnailers");
|
||||
search_dirs.push(data_home);
|
||||
}
|
||||
search_dirs.extend(xdg_dirs.get_data_dirs().into_iter().map(|mut data_dir| {
|
||||
data_dir.push("thumbnailers");
|
||||
data_dir
|
||||
}));
|
||||
|
||||
let mut thumbnailer_paths = Vec::new();
|
||||
for dir in search_dirs {
|
||||
log::trace!("looking for thumbnailers in {}", dir.display());
|
||||
match fs::read_dir(&dir) {
|
||||
Ok(entries) => {
|
||||
for entry_res in entries {
|
||||
match entry_res {
|
||||
Ok(entry) => thumbnailer_paths.push(entry.path()),
|
||||
Err(err) => {
|
||||
thumbnailer_paths.extend(entries.filter_map(|entry_res| {
|
||||
entry_res
|
||||
.inspect_err(|err| {
|
||||
log::warn!(
|
||||
"failed to read entry in directory {}: {}",
|
||||
dir.display(),
|
||||
err
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
})
|
||||
.ok()
|
||||
.map(|entry| entry.path())
|
||||
}));
|
||||
}
|
||||
Err(err) => {
|
||||
log::warn!("failed to read directory {}: {}", dir.display(), err);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue