diff --git a/.jules/bolt.md b/.jules/bolt.md index 99b76ee6d..77f44264b 100644 --- a/.jules/bolt.md +++ b/.jules/bolt.md @@ -42,6 +42,10 @@ **Learning:** Using `Array.from(map.values()).map(...)` creates an unnecessary intermediate array which wastes memory allocation and garbage collection time, particularly for frequently re-rendered components handling large collections. **Action:** Use a `for...of` loop over `map.values()` to iterate and push mapped elements directly into the final array for O(1) memory and avoiding intermediate array allocations. +## 2025-02-23 - Short-circuiting known absolute bounds +**Learning:** Using unconditional `.reduce()` to find a minimum or maximum value forces O(N) iteration, which is wasteful when an absolute bound (e.g., finding a 'low' confidence level) is known and can be found early. +**Action:** For performance optimizations involving finding a minimum/maximum value with a known absolute bound, replace unconditional `.reduce()` calls with a `for...of` loop and an early `break` to short-circuit the operation. + ## 2026-03-12 - O(1) early exit for confidence level **Learning:** Using `.reduce()` unconditionally iterates over the entire array for operations with an absolute bound (e.g. finding if there's any 'low' confidence section). **Action:** Replace unconditional `.reduce()` with a `for...of` loop and early `break` to short-circuit upon finding the minimum possible bound, changing O(N) worst-case into an O(K) best-case execution, yielding measurable performance gains on large documents.