1
0
mirror of https://github.com/emilk/egui.git synced 2026-09-01 14:20:04 -04:00

cargo fmt

This commit is contained in:
Emil Ernerfeldt
2025-04-01 18:41:39 +02:00
parent ff9dfdeec1
commit 6a5f6d3f86

View File

@@ -776,47 +776,54 @@ impl GalleyCache {
let hash = crate::util::hash(&job); // TODO(emilk): even faster hasher? let hash = crate::util::hash(&job); // TODO(emilk): even faster hasher?
(hash, match self.cache.entry(hash) { (
std::collections::hash_map::Entry::Occupied(entry) => { hash,
// The job was found in cache - no need to re-layout. match self.cache.entry(hash) {
let cached = entry.into_mut(); std::collections::hash_map::Entry::Occupied(entry) => {
cached.last_used = self.generation; // The job was found in cache - no need to re-layout.
let cached = entry.into_mut();
cached.last_used = self.generation;
let galley = cached.galley.clone(); let galley = cached.galley.clone();
if let Some(children) = &cached.children { if let Some(children) = &cached.children {
for child_hash in children.clone().iter() { for child_hash in children.clone().iter() {
if let Some(cached_child) = self.cache.get_mut(child_hash) { if let Some(cached_child) = self.cache.get_mut(child_hash) {
cached_child.last_used = self.generation; cached_child.last_used = self.generation;
}
} }
} }
}
galley
}
std::collections::hash_map::Entry::Vacant(entry) => {
let job = Arc::new(job);
if allow_split_paragraphs && should_cache_each_paragraph_individually(&job) {
let mut child_hashes = Vec::new();
let galley = self.layout_each_paragraph_individuallly(fonts, job, &mut child_hashes);
let galley = Arc::new(galley);
self.cache.insert(hash, CachedGalley {
last_used: self.generation,
children: Some(child_hashes.into()),
galley: galley.clone()
});
galley
} else {
let galley = super::layout(fonts, job);
let galley = Arc::new(galley);
entry.insert(CachedGalley {
last_used: self.generation,
children: None,
galley: galley.clone(),
});
galley galley
} }
} std::collections::hash_map::Entry::Vacant(entry) => {
}) let job = Arc::new(job);
if allow_split_paragraphs && should_cache_each_paragraph_individually(&job) {
let mut child_hashes = Vec::new();
let galley =
self.layout_each_paragraph_individuallly(fonts, job, &mut child_hashes);
let galley = Arc::new(galley);
self.cache.insert(
hash,
CachedGalley {
last_used: self.generation,
children: Some(child_hashes.into()),
galley: galley.clone(),
},
);
galley
} else {
let galley = super::layout(fonts, job);
let galley = Arc::new(galley);
entry.insert(CachedGalley {
last_used: self.generation,
children: None,
galley: galley.clone(),
});
galley
}
}
},
)
} }
fn layout( fn layout(
@@ -833,7 +840,7 @@ impl GalleyCache {
&mut self, &mut self,
fonts: &mut FontsImpl, fonts: &mut FontsImpl,
job: Arc<LayoutJob>, job: Arc<LayoutJob>,
child_hashes: &mut Vec<u64> child_hashes: &mut Vec<u64>,
) -> Galley { ) -> Galley {
profiling::function_scope!(); profiling::function_scope!();