fix(layer-state): share linetype list via Arc instead of cloning per row

editor_layer_row and view_editor took Vec<String>, cloning N strings per row per frame (times two build-closure runs). Both take Arc<[String]> now; a plain borrow cannot cross the twice-run closure (E0373), hence the Arc. Cow empty-filter short-circuit for both search queries. Test: view_editor_accepts_shared_linetypes (RED first). Full suite: 2029 passed / 0 failed / 25 ignored, zero warnings.
This commit is contained in:
Karim Jerbi committed 2026-10-11 02:17:18 +01:00
1 parent 9f9c621871
commit 15cfabdb0f
2 files changed
+62 -16

No files matched your search

+16 -8
View File
@@ -674,18 +674,26 @@ impl OpenCADStudio {
}
}
linetypes.sort_by_key(|name| name.to_lowercase());
// Shared ownership: the build closure runs twice per frame
// (INTRINSIC + FILL) and each row keeps its own copy, so a
// borrow cannot work here — an Arc clone per row is a
// refcount bump instead of N string clones (#21, cf. #34).
let linetypes = std::sync::Arc::<[String]>::from(linetypes);
sized_flow(
ex,
1180,
560,
|flow| {
crate::ui::window::layer_state_manager::view_editor(
state,
&self.layer_state_edit_filter,
self.layer_state_edit_color_open,
linetypes.clone(),
flow,
)
{
let linetypes = std::sync::Arc::clone(&linetypes);
move |flow| {
crate::ui::window::layer_state_manager::view_editor(
state,
&self.layer_state_edit_filter,
self.layer_state_edit_color_open,
std::sync::Arc::clone(&linetypes),
flow,
)
}
},
)
} else {