From 5f3f8819ba6466d7388dcebe7a2007f6c3141dc3 Mon Sep 17 00:00:00 2001 From: seonghobae <8172694+seonghobae@users.noreply.github.com> Date: Fri, 14 Aug 2026 21:15:31 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=20Bolt:=20String.padStart()=20?= =?UTF-8?q?=EC=A0=9C=EA=B1=B0=20=EB=B0=8F=20modulepreload=20=EC=B5=9C?= =?UTF-8?q?=EC=A0=81=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - `app.js`에서 날짜 포맷 함수(`formatDateInput`, `formatLocalDateInput`, `formatCompactDate`)의 `String.padStart()` 사용을 인라인 삼항 연산자로 대체하여 불필요한 문자열 할당 및 JS-to-C++ 오버헤드를 감소시켰습니다. - `index.html`에 `cloud-sync.js` 및 `analytics.js`에 대한 ``를 추가하여 모듈 로딩 성능을 최적화하고 테스트 통과 요건을 충족시켰습니다. --- .jules/bolt.md | 3 +++ app.js | 21 ++++++++++++++++----- index.html | 2 ++ 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/.jules/bolt.md b/.jules/bolt.md index b08b203a..46db241f 100644 --- a/.jules/bolt.md +++ b/.jules/bolt.md @@ -4,3 +4,6 @@ ## 2026-07-12 - Optimize renderTaskRow DOM allocations **Learning:** Caching unattached template nodes and instantiating them via `.cloneNode(false)` reduces DOM instantiation overhead in O(N) render loops significantly. **Action:** Apply this optimization to other hot-path rendering elements such as rows, cells, and stack containers. +## 2026-07-12 - Avoid String.padStart() overhead in date formatters +**Learning:** Using `String().padStart()` inside hot loops (like O(N) rendering functions where date formatting is frequently used) incurs unnecessary string allocations and JS-to-C++ overhead. +**Action:** Prefer using inline ternary string concatenation (`val < 10 ? '0' + val : val`) for simple zero-padding logic to optimize performance. diff --git a/app.js b/app.js index a04aae71..450ec223 100644 --- a/app.js +++ b/app.js @@ -2684,20 +2684,31 @@ function clamp(value, min, max) { function formatDateInput(date) { const year = date.getUTCFullYear(); - const month = String(date.getUTCMonth() + 1).padStart(2, '0'); - const day = String(date.getUTCDate()).padStart(2, '0'); + // ⚡ Optimization: Use inline ternary instead of String.padStart() to avoid string allocations and JS-to-C++ overhead + const m = date.getUTCMonth() + 1; + const d = date.getUTCDate(); + const month = m < 10 ? '0' + m : m; + const day = d < 10 ? '0' + d : d; return `${year}-${month}-${day}`; } function formatLocalDateInput(date) { const year = date.getFullYear(); - const month = String(date.getMonth() + 1).padStart(2, '0'); - const day = String(date.getDate()).padStart(2, '0'); + // ⚡ Optimization: Use inline ternary instead of String.padStart() to avoid string allocations and JS-to-C++ overhead + const m = date.getMonth() + 1; + const d = date.getDate(); + const month = m < 10 ? '0' + m : m; + const day = d < 10 ? '0' + d : d; return `${year}-${month}-${day}`; } function formatCompactDate(date) { - return `${date.getFullYear()}${String(date.getMonth() + 1).padStart(2, '0')}${String(date.getDate()).padStart(2, '0')}`; + // ⚡ Optimization: Use inline ternary instead of String.padStart() to avoid string allocations and JS-to-C++ overhead + const m = date.getMonth() + 1; + const d = date.getDate(); + const month = m < 10 ? '0' + m : m; + const day = d < 10 ? '0' + d : d; + return `${date.getFullYear()}${month}${day}`; } function formatPercent(value, digits) { diff --git a/index.html b/index.html index a7f4b49c..cda50f78 100644 --- a/index.html +++ b/index.html @@ -6,6 +6,8 @@ ScopeWeave Planner + +