Skip to content

Commit 6568b56

Browse files
committed
Also useMemo the 'total' row computation
1 parent 558d957 commit 6568b56

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

extensions/ql-vscode/src/view/compare-performance/ComparePerformance.tsx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -441,15 +441,17 @@ function ComparePerformanceWithData(props: {
441441
[nameSet, from, to, metric, hideCacheHits, sortOrder],
442442
);
443443

444-
let totalBefore = 0;
445-
let totalAfter = 0;
446-
let totalDiff = 0;
447-
448-
for (const row of rows) {
449-
totalBefore += metric.get(row.before);
450-
totalAfter += metric.get(row.after);
451-
totalDiff += row.diff;
452-
}
444+
const { totalBefore, totalAfter, totalDiff } = useMemo(() => {
445+
let totalBefore = 0;
446+
let totalAfter = 0;
447+
let totalDiff = 0;
448+
for (const row of rows) {
449+
totalBefore += metric.get(row.before);
450+
totalAfter += metric.get(row.after);
451+
totalDiff += row.diff;
452+
}
453+
return { totalBefore, totalAfter, totalDiff };
454+
}, [rows, metric]);
453455

454456
const rowNames = useMemo(
455457
() => abbreviateRANames(rows.map((row) => row.name)),

0 commit comments

Comments
 (0)