mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-13 22:21:59 +00:00
Three repairs in crates/pathops/src/addons/cleanup.rs grew with the square of the input. Each now gives the same results as before, bit for bit. - Collinear anchors: removing an anchor called Vec::remove, so a straight run of n anchors took O(n^2) moves. The repair now tests each anchor once against the nearest kept neighbors, with the same test order, neighbors and stop rule, and moves the kept anchors into place once. - Nearly Coincident Anchors (near_point_groups): every pair of anchors in touching grid cells was compared, so a cluster of A anchors cost O(A^2) checks. Groups now grow one anchor at a time and look only at anchors no group has taken, by exact position, skipping quarter-cell squares that lie out of reach. - Rejoin Path Pieces (rejoin): every pair of ends within the gap was listed and sorted, O(P^2 log P) for P pieces meeting at one place. Each end now finds its first partner in the same order (turn, distance, then end order), searching by direction among the ends still free, and two ends that are each other's first partner meet. Tests compare each repair with a copy of the old algorithm on generated and focused inputs, count the work on dense cases (20,000-anchor runs, 4,000-anchor clusters, 2,000 pieces meeting at one point), and check Health Check, Show and Fix on a 5,001-anchor path.