From 40d8141c32c9d1d404b845a808dff7c69f3a1e38 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Wed, 19 Aug 2026 11:35:51 +0000 Subject: [PATCH] perf(workspace): cache sheet list during invalidate loop 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: Horizontal42 <75383519+Horizontal42@users.noreply.github.com> --- src/workspace.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/workspace.ts b/src/workspace.ts index c6bb6a1..bc768b8 100644 --- a/src/workspace.ts +++ b/src/workspace.ts @@ -54,10 +54,11 @@ export class Workspace { invalidate(sheetId: string): void { this.titleCache = null; const dirty = new Set([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);