perf(workspace): cache sheet list during invalidate loop (#107)

Moved the evaluation of `this.sheets()` outside of the `while (changed)` invalidation loop to avoid redundant evaluations and allocations on deep dependency chains.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
This commit is contained in:
Horizontal42 2026-08-19 16:35:33 +03:00 • committed by GitHub
parent d166820b28
commit 19a9631709
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -54,10 +54,11 @@ export class Workspace {
invalidate(sheetId: string): void {
this.titleCache = null;
const dirty = new Set<string>([sheetId]);
const sheetsList = this.sheets();
let changed = true;
while (changed) {
changed = false;
for (const s of this.sheets()) {
for (const s of sheetsList) {
if (dirty.has(s.id)) continue;
for (const title of this.referencedTitles(s.text, s.id)) {
const target = this.findSheetByTitle(title);