mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-10-26 02:37:01 -06:00
The previous commit rebuilt the cache as soon as a cached path went stale, and built it as one Vec path per node, hashed with SipHash. An edit that removes many objects one by one (Pathfinder Unite of 1,000 paths) went stale on every removal, and Unite took 105 ms instead of 42 ms. - The cache is now one flat table of (parent entry, index among siblings) with a one-multiply id hasher, so a rebuild is about one walk and allocates nothing per node. - A stale path walks, as an id the cache doesn't have does, and rebuilds only after a few. Either way a lookup stays within a small factor of a walk. At 1,000 paths, Unite takes 45 ms against main's 42. At 100,000 paths the gains of the cache hold: hit test 1.7 → 0.36 ms, handle drag 6.5 → 2.7 ms per move. The cached-lookup tests pass unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VmMmc1J8XeNLxhRihWv9cc