forked from 1b-agent/opencadstudio-upstream
perf(statusbar): cache layout/scale derived data behind epochs (major)
Status bar rescanned the whole object map twice per frame (layout_names + scale_picker_list), deep-cloned an already-cached Arc, and built two undo/redo label vecs consumed ~never. Cache layout names (epoch key) and scale picker (epoch + unit-factor + imperial-family + current-scale key) as Arc behind choke-point invalidation (layout/scale impl methods, undo/redo swaps, file-open, doc-reset); borrow across the widget boundary (owned-Arc params; E0515 forbids &'a slices over call-site temporaries); build undo/redo labels only when their dropdown is open. Tests: - cached_layout_names_returns_same_arc_until_bump: hit-path Arc identity - cached_layout_names_invalidated_by_add_layout: bump yields new Arc + names - cached_scale_picker_returns_same_arc_until_bump: hit-path Arc identity - cached_scale_picker_invalidated_by_add_scale: bump yields new Arc + scale - cached_scale_picker_invalidated_by_current_scale_change: key completeness Bench (cargo bench ui_statusbar_derived_data, 3k entities): cached hit below timer granularity vs ~1us uncached scans, PASS (50us threshold).
This commit is contained in:
1 parent
baba5bccd3
commit
dcc05f310d
16 files changed
+327
-43
No files matched your search
@@ -22,12 +22,21 @@ impl Scene {
|
||||
self.model_pane_min_px.clone()
|
||||
}
|
||||
|
||||
/// Create a paper-space layout. Wraps `document.add_layout` so the
|
||||
/// cached layout-name list is invalidated on insert.
|
||||
pub fn add_layout(&mut self, name: &str) -> acadrust::Result<Handle> {
|
||||
let handle = self.document.add_layout(name)?;
|
||||
self.bump_layout_epoch();
|
||||
Ok(handle)
|
||||
}
|
||||
|
||||
/// Rename a paper-space layout. Updates the Layout object name in the document.
|
||||
pub fn rename_layout(&mut self, old_name: &str, new_name: &str) {
|
||||
for obj in self.document.objects.values_mut() {
|
||||
if let ObjectType::Layout(l) = obj {
|
||||
if l.name == old_name {
|
||||
l.name = new_name.to_string();
|
||||
self.bump_layout_epoch();
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -96,6 +105,7 @@ impl Scene {
|
||||
}
|
||||
|
||||
self.bump_geometry();
|
||||
self.bump_layout_epoch();
|
||||
true
|
||||
}
|
||||
|
||||
@@ -123,6 +133,7 @@ impl Scene {
|
||||
}
|
||||
}
|
||||
}
|
||||
self.bump_layout_epoch();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,6 +150,7 @@ impl Scene {
|
||||
}
|
||||
}
|
||||
}
|
||||
self.bump_layout_epoch();
|
||||
}
|
||||
|
||||
/// Rebuild the `pane_grid` layout from the current `model_tiles` rects
|
||||
|
||||
Reference in new issue
Block a user