mirror of
https://github.com/storytold/cadcraft.git
synced 2026-12-01 10:13:53 -06:00
Drawing::layer scanned every layer, and Drawing::block scanned every block when the exact name missed. Both run once per entity while a drawing is read, measured and inspected, so a file with N layers, or with N blocks and N references to blocks it doesn't have, opened in N² comparisons (40 000 missing-block references: 75.7 s in a dev build; 40 000 layers: 6.8 s). Drawing::layers is now a NamedList<Layer> and Drawing::blocks a NamedMap<Arc<Block>>. They read and change as the Vec and BTreeMap they wrap, and keep an index from a keyed hash of the case-folded name to the first entry of that hash. A hit is checked against the name and falls back to the scan, so results are the same as before: same case rule, first match in table order, exact block name first. Every change goes through DerefMut, which drops the index; a clone (undo snapshot) shares it. The index is built only for tables of 64 entries or more, after 32 scans since the last change, so code that changes a table between lookups costs what it did. Part of #1924 (F-04). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>