mirror of
https://github.com/penpot/penpot.git
synced 2026-07-22 22:17:58 +00:00
⚡ cache shape depth in reflow sort
This commit is contained in:
parent
acce410f78
commit
6022f070eb
@ -482,11 +482,8 @@ pub fn propagate_modifiers(
|
||||
// are already reflowed before their parents.
|
||||
let mut layout_reflows_vec: Vec<Uuid> =
|
||||
std::mem::take(&mut layout_reflows).into_iter().collect();
|
||||
layout_reflows_vec.sort_unstable_by(|id_a, id_b| {
|
||||
let da = shapes.get_depth(id_a);
|
||||
let db = shapes.get_depth(id_b);
|
||||
db.cmp(&da)
|
||||
});
|
||||
// Deepest-first; cache get_depth (O(depth) parent walk) per id.
|
||||
layout_reflows_vec.sort_by_cached_key(|id| std::cmp::Reverse(shapes.get_depth(id)));
|
||||
|
||||
// This temporary bounds is necesary so the layouts can be calculated
|
||||
// correctly but will be discarded before the next iteration for the
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user