Skip to content

Commit af36b26

Browse files
committed
[PERF] evaluation: stop the dependencies search early
From 40s to ~7s closes #7239 Task: 4954710 Signed-off-by: Rémi Rahir (rar) <rar@odoo.com>
1 parent b796c32 commit af36b26

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
@@ -406,7 +406,8 @@ export class Evaluator {
406406
private invalidatePositionsDependingOnSpread(sheetId: UID, resultZone: Zone) {
407407
// the result matrix is split in 2 zones to exclude the array formula position
408408
const invalidatedPositions = this.formulaDependencies().getCellsDependingOn(
409-
excludeTopLeft(resultZone).map((zone) => ({ sheetId, zone }))
409+
excludeTopLeft(resultZone).map((zone) => ({ sheetId, zone })),
410+
this.nextPositionsToUpdate
410411
);
411412
invalidatedPositions.delete({ sheetId, col: resultZone.left, row: resultZone.top });
412413
this.nextPositionsToUpdate.addMany(invalidatedPositions);
@@ -564,7 +565,7 @@ export class Evaluator {
564565
for (const sheetId in zonesBySheetIds) {
565566
ranges.push(...zonesBySheetIds[sheetId].map((zone) => ({ sheetId, zone })));
566567
}
567-
return this.formulaDependencies().getCellsDependingOn(ranges);
568+
return this.formulaDependencies().getCellsDependingOn(ranges, this.nextPositionsToUpdate);
568569
}
569570
}
570571

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)