Skip to content

Commit 018e7a8

Browse files
committed
[PERF] evaluation: stop the dependencies search early
From 40s to ~7s closes #7308 Task: 4954710 X-original-commit: af36b26 Signed-off-by: Rémi Rahir (rar) <rar@odoo.com> Signed-off-by: Lucas Lefèvre (lul) <lul@odoo.com>
1 parent 67031f4 commit 018e7a8

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/plugins/ui_core_views/cell_evaluation/evaluator.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,8 @@ export class Evaluator {
410410
private invalidatePositionsDependingOnSpread(sheetId: UID, resultZone: Zone) {
411411
// the result matrix is split in 2 zones to exclude the array formula position
412412
const invalidatedPositions = this.formulaDependencies().getCellsDependingOn(
413-
excludeTopLeft(resultZone).map((zone) => ({ sheetId, zone }))
413+
excludeTopLeft(resultZone).map((zone) => ({ sheetId, zone })),
414+
this.nextPositionsToUpdate
414415
);
415416
invalidatedPositions.delete({ sheetId, col: resultZone.left, row: resultZone.top });
416417
this.nextPositionsToUpdate.addMany(invalidatedPositions);
@@ -571,7 +572,7 @@ export class Evaluator {
571572
for (const sheetId in zonesBySheetIds) {
572573
ranges.push(...zonesBySheetIds[sheetId].map((zone) => ({ sheetId, zone })));
573574
}
574-
return this.formulaDependencies().getCellsDependingOn(ranges);
575+
return this.formulaDependencies().getCellsDependingOn(ranges, this.nextPositionsToUpdate);
575576
}
576577
}
577578

src/plugins/ui_core_views/cell_evaluation/formula_dependency_graph.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export class FormulaDependencyGraph {
5858
* in the correct order they should be evaluated.
5959
* This is called a topological ordering (excluding cycles)
6060
*/
61-
getCellsDependingOn(ranges: RTreeBoundingBox[]): PositionSet {
61+
getCellsDependingOn(ranges: RTreeBoundingBox[], ignore: PositionSet): PositionSet {
6262
const visited = this.createEmptyPositionSet();
6363
const queue: RTreeBoundingBox[] = Array.from(ranges).reverse();
6464
while (queue.length > 0) {
@@ -74,7 +74,7 @@ export class FormulaDependencyGraph {
7474
const impactedPositions = this.rTree.search(range).map((dep) => dep.data);
7575
const nextInQueue: Record<UID, Zone[]> = {};
7676
for (const position of impactedPositions) {
77-
if (!visited.has(position)) {
77+
if (!visited.has(position) && !ignore.has(position)) {
7878
if (!nextInQueue[position.sheetId]) {
7979
nextInQueue[position.sheetId] = [];
8080
}

0 commit comments

Comments
 (0)