Skip to content

Commit

Permalink
[FIX] sheetview: Avoid useless cleanViewport
Browse files Browse the repository at this point in the history
cleanViewports is called at every command handling in `SheetViewPlugin`
but it only makes sense do to so for commands that could actually impact
the internal viewport mapping of the plugin. Namely,
UNDO/REDO/DELETE_SHEET commands could have an impact on that mapping.

This revision limits the calls to cleanViewports for those specific
commands.

When deleting a row on a sheet of 26*10_000 cells, this spares around
100ms of computation.

closes #4935

Task: 4084860
X-original-commit: 2f97267
Signed-off-by: Lucas Lefèvre (lul) <[email protected]>
Signed-off-by: Rémi Rahir (rar) <[email protected]>
  • Loading branch information
rrahir committed Sep 2, 2024
1 parent 84bf187 commit ed16095
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/plugins/ui_stateful/sheetview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ export class SheetViewPlugin extends UIPlugin {
}

handle(cmd: Command) {
this.cleanViewports();
// changing the evaluation can hide/show rows because of data filters
if (invalidateEvaluationCommands.has(cmd.type)) {
for (const sheetId of this.getters.getSheetIds()) {
Expand All @@ -185,6 +184,7 @@ export class SheetViewPlugin extends UIPlugin {
break;
case "UNDO":
case "REDO":
this.cleanViewports();
for (const sheetId of this.getters.getSheetIds()) {
this.sheetsWithDirtyViewports.add(sheetId);
}
Expand Down Expand Up @@ -239,6 +239,9 @@ export class SheetViewPlugin extends UIPlugin {
}
}
break;
case "DELETE_SHEET":
this.cleanViewports();
break;
case "ACTIVATE_SHEET":
this.sheetsWithDirtyViewports.add(cmd.sheetIdTo);
break;
Expand Down

0 comments on commit ed16095

Please sign in to comment.