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:
Cheong Lau 2025-10-28 13:10:40 +10:00
parent 5f729829d7
commit bd1fa1f0a9
16 changed files with 971 additions and 1109 deletions

View file

@ -75,21 +75,17 @@ pub enum Favorite {
impl Favorite {
pub fn from_path(path: PathBuf) -> Self {
// Ensure that special folders are handled properly
for favorite in &[
[
Self::Home,
Self::Documents,
Self::Downloads,
Self::Music,
Self::Pictures,
Self::Videos,
] {
if let Some(favorite_path) = favorite.path_opt() {
if favorite_path == path {
return favorite.clone();
}
}
}
Self::Path(path)
]
.into_iter()
.find(|fav| fav.path_opt().as_ref() == Some(&path))
.unwrap_or(Self::Path(path))
}
pub fn path_opt(&self) -> Option<PathBuf> {