From 58ba2e2008b70837f65b1c51f279f8dfeef7716c Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Wed, 22 Apr 2026 09:03:59 +0000 Subject: [PATCH] perf(heatmap): optimize maxFreq calculation with reduce Replaces map and spread syntax with a single reduce call to calculate maxFreq in the Heatmap component, eliminating redundant array allocation and preventing potential call stack exhaustion. Co-authored-by: artosien <65523959+artosien@users.noreply.github.com> --- src/components/analytics/heatmap.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/analytics/heatmap.tsx b/src/components/analytics/heatmap.tsx index 531133c..44aa098 100644 --- a/src/components/analytics/heatmap.tsx +++ b/src/components/analytics/heatmap.tsx @@ -82,7 +82,7 @@ export function LotteryHeatmap() { setGeneratedSet([]) }, [lottoType, timeframe, activeGame.max]) - const maxFreq = Math.max(...numbers.map(n => n.frequency), 1) + const maxFreq = numbers.reduce((max, n) => Math.max(max, n.frequency), 1) const getTemperatureColor = (freq: number) => { const ratio = freq / maxFreq