summarum/.jules/bolt.md
google-labs-jules[bot] c9c138e971 perf: O(1) cycle detection for Workspace cross-sheet refs
Change Workspace.resolving stack from string[] to Set<string> to make cycle detection check O(1) instead of O(N).

Co-authored-by: Horizontal42 <75383519+Horizontal42@users.noreply.github.com>
2026-07-08 09:15:25 +00:00

653 B

2023-11-20 - O(1) Cycle Detection in Workspace resolving

Learning: When resolving deep, interdependent variables across sheets, checking a string[] stack for cycles using .includes() can degrade performance significantly (O(N) lookup repeatedly). Changing the stack representation to a Set<string> improves the check to O(1) and substantially drops resolution time from ~180ms to ~0.5ms under load.

Action: Whenever a unique set of items is tracked primarily for existence checking (like a cycle detection or "visiting" stack), prefer Set over Array if sequence order is not strictly necessary or if removal by value is possible.