Many separate regions made the nesting depth test every pair of contours,
Douglas-Peucker could rescan a span once per point (and recurse as deep as
the loop is long), and the curve fit searched the raw contour from its start
for every simplified vertex.
- Depth: each loop's bounding box goes into a coarse grid; a loop's first
point is tested only against loops whose box holds it. Same depths as
testing every pair.
- Douglas-Peucker: spans wait on an explicit stack, with a budget of 64
distance evaluations per point; spans still waiting when it runs out keep
all their points, so the outline stays exact.
- Fitting: uses the raw indices the simplifier kept instead of searching.