Files
vectorcraft/crates
dotCooCoo 0b8dae1401 Delete: removing objects one at a time keeps the id lookup cache
Every Document::remove_many cleared the id lookup cache, and the next
lookup with no cache walked the tree once to answer and again to
rebuild it. Deleting objects one by id at a time with edit.clear walked
the whole tree twice per Delete: 20,005 walks for 10,000 objects.

- remove_many keeps the cache and records which children it took out
  of each parent. A cached path then counts a node's index among its
  siblings less the removed siblings before it, so the nodes left are
  found without a walk whichever objects were removed (top, bottom,
  middle, or the art below a layer's ruler guides). The cache has no
  path for a removed node or a node inside one. The cache is still
  dropped once the removed nodes are half of its entries, and when it
  does not have a listed node where it is.
- index_path with no cache builds the cache and answers from it, in
  one walk. An id that appears more than once is still walked to, so
  the first in tree order is returned as before.

Release build, deleting each object of one layer by id with nothing
selected. Walks for 1,000 objects went from 2,005 to 14 in each order.
For 10,000 objects, median of three runs:

  from the top:     20,005 walks, 5.53 s  -> 15 walks, 4.28 s
  from the bottom:  20,005 walks, 11.24 s -> 15 walks, 10.87 s
  from the middle:  20,005 walks, 10.62 s -> 15 walks, 8.62 s

Each Delete is still one undo step. The time left still grows with the
square of the count: each Delete rebuilds the parent's child list and
keeps a copy of the document for undo, and this change does not touch
either.
2026-11-22 17:06:53 -08:00
..
…
…