From 0fdd3bb3d06b7d25e7f2c1178d18acd0d49d7eec Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sat, 25 Apr 2026 20:52:39 +0000 Subject: [PATCH] perf: optimize heatmap max freq calculation using reduce Changed `Math.max(...numbers.map(n => n.frequency), 1)` to `numbers.reduce((max, n) => Math.max(max, n.frequency), 1)` to avoid redundant array allocations. 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