Skip to content

Commit 6c6f902

Browse files
committed
[PERF] history: faster history at import
The history is sometimes used in plugin `import` methods: `this.history.update(...)` There are 2 main reason to do that: - data structures are typed as readonly (to force using the history when handling commands) - it's easier since it creates all intermediary objects itself `this.history.update("myData", sheetId, pivotId, value)`, if `myData` is empty, it will creates intermediary objects with keys `sheetId` and `pivotId`: `myData: { [sheetId]: { [pivotId]: data } }` At import however, keeping track of the changes is useless. They are currently aggregated in the `changes` array, but never used. This commit improves loading time of the large number data set by ~17% Before: 1353ms After: 1116ms (averages over 8 runs) closes #4732 Task: 4083517 X-original-commit: 3868552 Signed-off-by: Rémi Rahir (rar) <[email protected]> Signed-off-by: Lucas Lefèvre (lul) <[email protected]>
1 parent 9b5a522 commit 6c6f902

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/state_observer.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { CoreCommand, HistoryChange } from "./types";
44
type HistoryPath = [any, ...(number | string)[]];
55

66
export class StateObserver {
7-
private changes: HistoryChange[] = [];
7+
private changes: HistoryChange[] | undefined;
88
private commands: CoreCommand[] = [];
99

1010
/**
@@ -39,7 +39,7 @@ export class StateObserver {
3939
if (value[key] === val) {
4040
return;
4141
}
42-
this.changes.push({
42+
this.changes?.push({
4343
key,
4444
target: value,
4545
before: value[key],

0 commit comments

Comments
 (0)