mirror of
https://github.com/Horizontal42/summarum.git
synced 2026-11-10 15:42:01 +03:00
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:
parent
d166820b28
commit
19a9631709
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