Skip to content

Commit

Permalink
[FIX] cells: faster getter to get cell
Browse files Browse the repository at this point in the history
getCellById self-time was ~13.6% and is now ~9.1% (average over 5 runs)

opw-3588401

closes #3189

Task: 3588401
X-original-commit: 0d9bf0c
Signed-off-by: Rémi Rahir (rar) <[email protected]>
Signed-off-by: Lucas Lefèvre (lul) <[email protected]>
  • Loading branch information
LucasLefevre committed Nov 17, 2023
1 parent 95569a7 commit f01711b
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/plugins/core/cell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,14 +275,9 @@ export class CellPlugin extends CorePlugin<CoreState> implements CoreState {
*/
getCellById(cellId: UID): Cell | undefined {
// this must be as fast as possible
for (const sheetId in this.cells) {
const sheet = this.cells[sheetId];
const cell = sheet[cellId];
if (cell) {
return cell;
}
}
return undefined;
const position = this.getters.getCellPosition(cellId);
const sheet = this.cells[position.sheetId];
return sheet[cellId];
}

/*
Expand Down

0 comments on commit f01711b

Please sign in to comment.