diff --git a/.github/workflows/pr-checks.yml b/.github/workflows/pr-checks.yml index 4131c473b..404c190f2 100644 --- a/.github/workflows/pr-checks.yml +++ b/.github/workflows/pr-checks.yml @@ -354,12 +354,11 @@ jobs: return 'skip'; } function latestIso(values) { - const times = values - .map(value => Date.parse(value)) - .filter(Number.isFinite); - return times.length > 0 - ? new Date(Math.max(...times)).toISOString() - : null; + const maxTime = values.reduce((max, val) => { + const time = Date.parse(val); + return Number.isFinite(time) && time > max ? time : max; + }, -Infinity); + return maxTime > -Infinity ? new Date(maxTime).toISOString() : null; } function workflowRunId(targetUrl) { const target = String(targetUrl || ''); diff --git a/.jules/bolt.md b/.jules/bolt.md index fa5a3cfc9..d458b9bdc 100644 --- a/.jules/bolt.md +++ b/.jules/bolt.md @@ -16,4 +16,4 @@ **Action:** Extract pure transformation logic on static/infrequent data into `useMemo` hooks (e.g., memoizing the paragraph split on `transcript` and precomputing search `RegExp` based on `searchQuery`). ## 2026-07-24 - Avoiding spread operator for large arrays in calculations **Learning:** Using `Math.max(...array.map())` on potentially large data structures runs the risk of hitting the "Maximum call stack size exceeded" error, and creates unnecessary intermediate array allocations, reducing performance. -**Action:** Replace multiple O(N) array mapping and spread operations with a single O(N) `for` loop to compute bounds simultaneously with zero intermediate allocations. +**Action:** Replace multiple O(N) array mapping and spread operations with a single O(N) `for` loop to compute bounds simultaneously with zero intermediate allocations. Or in cases finding the max of parsed strings, use a `.reduce()` loop for a safe single pass without generating intermediate array structures.