mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-18 16:37:32 +00:00
DocState::proxy_mixed, which decides whether the Fill and Stroke proxies show "?", walked every node of the document to find the selected objects, even with one object selected. The Tools panel proxies, the paint chips and the task bar ask for it on every frame whose revision changed, which includes each frame of a drag preview, and new art asks for it after a selection change. Document::nodes_in_order finds every node with one of the given ids in tree order. When the id cache holds each id once at a path that still checks out, it reads the nodes along those paths; otherwise, and for a selection of an eighth of the document or more, it walks the tree once, as before. Unlike Document::index_paths it returns every node with a repeated id, so a damaged file that repeats an id keeps the question marks it had. proxy_mixed now gathers the selected objects through it. Tests compare the result with a copy of the old walk for one object, different fills and strokes, a group, a group with one of its objects, two layers, a hidden object, Appearance items, picked gradient mesh points beside another object, ids not in the document and a repeated id with different paints, with the cache built and dropped, and for 200 random selections. A cost test shows that with one object selected only that object is read and the tree is not walked. Document tests compare nodes_in_order with a walk. The gain shows on large documents. On 50,000 rectangles in 500 groups on 5 layers (release build on Linux, thread CPU time, median of seven alternating runs of both versions in one process; an ignored test, proxy_mixed_timing, times them): Selection old new 1 object 995 us under 5 us 2 objects, different fills 810 us under 5 us a group of 100 875 us 5 us all 500 groups 3,615 us 2,575 us all 50,000 objects 4,075 us 3,470 us