mirror of
https://github.com/Horizontal42/summarum.git
synced 2026-11-11 01:02:01 +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 {
|
invalidate(sheetId: string): void {
|
||||||
this.titleCache = null;
|
this.titleCache = null;
|
||||||
const dirty = new Set<string>([sheetId]);
|
const dirty = new Set<string>([sheetId]);
|
||||||
|
const sheetsList = this.sheets();
|
||||||
let changed = true;
|
let changed = true;
|
||||||
while (changed) {
|
while (changed) {
|
||||||
changed = false;
|
changed = false;
|
||||||
for (const s of this.sheets()) {
|
for (const s of sheetsList) {
|
||||||
if (dirty.has(s.id)) continue;
|
if (dirty.has(s.id)) continue;
|
||||||
for (const title of this.referencedTitles(s.text, s.id)) {
|
for (const title of this.referencedTitles(s.text, s.id)) {
|
||||||
const target = this.findSheetByTitle(title);
|
const target = this.findSheetByTitle(title);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue