From 72e73c645b63d3b90a232d4c1022b40e9db6b17d Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 6 Mar 2026 07:42:51 +0000 Subject: [PATCH] perf: optimize dynamic array creation in SamplingErrorModule Replaced Array.from calls in SamplingErrorModule.tsx with more efficient alternatives: a static array for the grid cells and new Array().fill() for the dynamic simulation cells. This reduces memory allocations and CPU overhead during component renders. Co-authored-by: ChaunceyCHI <58379404+ChaunceyCHI@users.noreply.github.com> --- components/modules/SamplingErrorModule.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/components/modules/SamplingErrorModule.tsx b/components/modules/SamplingErrorModule.tsx index 8fe0868..6c88c80 100644 --- a/components/modules/SamplingErrorModule.tsx +++ b/components/modules/SamplingErrorModule.tsx @@ -1,6 +1,8 @@ import React, { useState } from 'react'; import { Microscope, Info, AlertCircle, CheckCircle2 } from 'lucide-react'; +const GRID_CELLS = Array.from({ length: 16 }); + const SamplingErrorModule: React.FC = () => { const [isShaken, setIsShaken] = useState(false); const [samplingPosition, setSamplingPosition] = useState<'top' | 'bottom' | null>(null); @@ -132,13 +134,13 @@ const SamplingErrorModule: React.FC = () => { {/* The circular view */}
- {Array.from({length: 16}).map((_, i) =>
)} + {GRID_CELLS.map((_, i) =>
)}
{/* Cells Simulation */} {result ? (
- {Array.from({ length: Math.floor(result.count / 10) }).map((_, i) => ( + {new Array(Math.floor(result.count / 10)).fill(0).map((_, i) => (