From e5313f5717ae570be3bb47d31f54b48ed26536cf 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 20:50:31 +0000 Subject: [PATCH] perf: optimize maxFreq calculation in heatmap Replaced `Math.max(...numbers.map())` with `.reduce()` to eliminate redundant array allocation and improve performance. This avoids O(N) array allocation overhead. 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