mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-10-26 10:47:11 -06:00
Follow-up to #4021. The grid filed each piece of a segment under its cells without checking, so a degenerate grid (collinear horizontal lines: cells a hundred points wide and a hair tall) stored one segment ~400 times per cell, and coincident vertical segments (one column, a row per segment) filed every segment under every row: a quadratic number of references, about a GiB for 16,384 segments within the Shape Builder's limit. Now a segment is filed once per cell (its pieces come in order, so the cell's last entry is enough to check), and the grid holds a budget of references (64 per item plus four rows' or columns' worth, `reference_budget`); the items past it go to the scanned list, so the index stays O(n·sqrt(n)) in memory and every lookup still finds every segment through its point. Regression: `rect_index_holds_a_bounded_number_of_references` (fails without the change: 4,100 references per cell for ten collinear lines). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014gCpjL3yUhaH3jRp7ksufh