A Shift-drag marquee sends every object it reaches as one select.toggle
{ids}. Each id used to scan and rebuild the selected objects, so K ids
against S selected objects took O(K*(S+K)). Selection::toggle_all and
Selection::add_all now handle the ids in one pass with a map of each id's
current slot, and the commands use them. The result is the same as
toggling or adding each id in order: an id toggled twice is selected
again at the end, and a removal clears that id's anchors, segments, key
and key anchor.
Select > Inverse looks each selectable object up in a set of the
selected ones instead of scanning the selection for each.
Selection::toggle_target, set_slices and set_guides use the same set
lookups.
crates/engine/examples/selection_bench.rs times the old per-id loops
against the new ones in one process. With 50,000 objects, toggling every
object off took 528 to 655 ms before and 2.5 to 4.6 ms after in 7 runs
(wall clock on a machine that was running other builds).