forked from 1b-agent/opencadstudio-upstream
perf: stop rescanning every entity to fill the selection-filter menu
Pan and even plain cursor movement over the canvas ran at ~8 fps on a large drawing. Nothing rendered was responsible: the GPU idled at 0-8%, encoding no scene at all changed nothing, and vertices, pixels and draw calls could each be cut without moving the number. `view` was the frame -- 110 ms of it against 3-6 ms on a small drawing -- and inside `view` it was the status bar. The status bar builds the selection-filter menu, which asks for the distinct entity type names in the layout. That call cloned the layout's entire handle list (1 166 357 handles, ~9 MB), then did a map lookup, a String allocation and a BTreeSet insert for each one. About 107 ms of a 110 ms frame, to produce roughly twenty names, for a menu that is only visible when opened. Cache the result against geometry_epoch and the layout block, since it only changes when entities are added or removed, and make the scan itself borrow the handle list rather than clone it and collect &str, allocating only for the names it returns. The immediate-mode UI rebuilds every widget on every mouse move, which is fine as long as nothing in that path is O(document). This was. Co-Authored-By: Claude Opus 5 <[email protected]>
This commit is contained in:
1 parent
886d5777d8
commit
f1efc73cbe
4 files changed
+51
-12
No files matched your search
@@ -3687,8 +3687,8 @@ impl OpenCADStudio {
|
||||
let i = self.active_tab;
|
||||
let types = self.tabs[i].scene.entity_type_names_in_layout();
|
||||
let f = &mut self.tabs[i].scene.selection_filter;
|
||||
for t in types {
|
||||
f.insert(t.to_string());
|
||||
for t in types.iter() {
|
||||
f.insert(t.clone());
|
||||
}
|
||||
Task::none()
|
||||
}
|
||||
|
||||
+2
-3
@@ -1948,9 +1948,8 @@ impl OpenCADStudio {
|
||||
selection_types: tab
|
||||
.scene
|
||||
.entity_type_names_in_layout()
|
||||
.into_iter()
|
||||
.map(|name| name.to_string())
|
||||
.collect(),
|
||||
.as_ref()
|
||||
.clone(),
|
||||
selection_filter: &tab.scene.selection_filter,
|
||||
tooltip_hidden: self.status_menu_tooltip_hidden,
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user