forked from 1b-agent/opencadstudio-upstream
Viewport block caches no longer scan every object per entity
A drawing with 650k entities and 21k objects stalled for 7 minutes the first time a layout viewport was drawn (#1746): building that viewport's block cache asked for each entity's layer viewport overrides, and the codec found each layer's extension dictionary by scanning every object whenever the layer had none. Codec 2646725 reads the registered link. The XCLIP check made the same scan for every nested INSERT without an extension dictionary; it now reads the INSERT's own link, which the readers and ensure_extension_dictionary always set. Cargo: codec 2646725, kernel 4e6334a, graph 2fd1d42. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5f5b64ef70
commit
3a3d2e4a84
8 files changed
+22
-25
No files matched your search
+8
-11
@@ -48,15 +48,12 @@ fn resolve_extension_dictionary(doc: &CadDocument, owner: Handle) -> Option<Hand
|
||||
})
|
||||
}
|
||||
|
||||
/// The INSERT's extension dictionary through its own link or the document's
|
||||
/// index — both O(1). Render walks ask this for every INSERT, so it must not
|
||||
/// fall back to [`resolve_extension_dictionary`]'s scan of every object.
|
||||
fn linked_extension_dictionary(doc: &CadDocument, ins: &Insert) -> Option<Handle> {
|
||||
ins.common
|
||||
.xdictionary_handle
|
||||
.filter(|h| !h.is_null())
|
||||
.or_else(|| doc.extension_dictionary_handle(ins.common.handle))
|
||||
.filter(|h| !h.is_null())
|
||||
/// The INSERT's extension dictionary through its own link. Render walks ask
|
||||
/// this for every INSERT, so it must not fall back to a scan of every object:
|
||||
/// [`CadDocument::extension_dictionary_handle`] scans for an entity without
|
||||
/// a linked dictionary. Readers and `ensure_extension_dictionary` set the link.
|
||||
fn linked_extension_dictionary(ins: &Insert) -> Option<Handle> {
|
||||
ins.common.xdictionary_handle.filter(|h| !h.is_null())
|
||||
}
|
||||
|
||||
/// Resolve the enabled XCLIP spatial filter for `ins`, if any.
|
||||
@@ -66,7 +63,7 @@ fn linked_extension_dictionary(doc: &CadDocument, ins: &Insert) -> Option<Handle
|
||||
/// filter, it is disabled (code 71 = 0), or it has fewer than two boundary
|
||||
/// points.
|
||||
pub fn insert_spatial_filter<'a>(doc: &'a CadDocument, ins: &Insert) -> Option<&'a SpatialFilter> {
|
||||
let xdict = linked_extension_dictionary(doc, ins)?;
|
||||
let xdict = linked_extension_dictionary(ins)?;
|
||||
let acad_filter = dict_entry(doc, xdict, "ACAD_FILTER")?;
|
||||
let spatial = dict_entry(doc, acad_filter, "SPATIAL")?;
|
||||
match doc.objects.get(&spatial)? {
|
||||
@@ -84,7 +81,7 @@ pub fn filter_handle(doc: &CadDocument, insert: Handle) -> Option<Handle> {
|
||||
let Some(codec::EntityType::Insert(ins)) = doc.get_entity(insert) else {
|
||||
return None;
|
||||
};
|
||||
let xdict = linked_extension_dictionary(doc, ins)?;
|
||||
let xdict = linked_extension_dictionary(ins)?;
|
||||
let acad_filter = dict_entry(doc, xdict, "ACAD_FILTER")?;
|
||||
let spatial = dict_entry(doc, acad_filter, "SPATIAL")?;
|
||||
matches!(
|
||||
|
||||
Reference in new issue
Block a user