forked from 1b-agent/opencadstudio-upstream
fix(field): skip the drawing snapshot when a plot has no field to stamp
#1590 cloned the whole document on every plot to evaluate plot-time fields, even in drawings without a single FIELD; a large drawing paid a full copy per plot. The copy is made only when the drawing holds fields. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
29ed1cae9b
commit
3f54f2f494
1 file changed
+9
@@ -382,6 +382,15 @@ pub fn block_has_attribute_fields(document: &CadDocument, block: &str) -> bool {
|
||||
/// Give plot-time fields (PlotDate) the plot's time; returns the hosts whose
|
||||
/// text changed.
|
||||
pub fn stamp_plot_fields(document: &mut CadDocument) -> Vec<Handle> {
|
||||
// The context reads a snapshot of the whole drawing; most drawings hold
|
||||
// no field, and a large one should not be copied for every plot.
|
||||
let has_fields = document
|
||||
.objects
|
||||
.values()
|
||||
.any(|object| matches!(object, codec::objects::ObjectType::Field(_)));
|
||||
if !has_fields {
|
||||
return Vec::new();
|
||||
}
|
||||
let snapshot = document.clone();
|
||||
let context = PlotContext(OcsFieldContext(Some(&snapshot)));
|
||||
document.stamp_plot_fields(&context)
|
||||
|
||||
Reference in new issue
Block a user