mirror of
https://github.com/Horizontal42/summarum.git
synced 2026-11-11 02:12:00 +03:00
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>
This commit is contained in:
parent
868a34497b
commit
40d8141c32
1 changed files with 2 additions and 1 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue