⚡ Bolt: [performance improvement] Pre-index search string and date formatting#73
⚡ Bolt: [performance improvement] Pre-index search string and date formatting#73MrAlokTech wants to merge 1 commit intomainfrom
Conversation
…rmatting - Added `prepareSearchIndex` helper to pre-calculate `_searchStr`, `_isNew`, and `_formattedDate` for all PDF items using `Intl.DateTimeFormat`. - Invoked `prepareSearchIndex` in `loadPDFDatabase` immediately after retrieving data from Firestore or Cache. - Modified `renderPDFs` and `createPDFCard` to prioritize these pre-calculated properties over running regex/date-parsing during render loops, including safe fallback mechanisms. Co-authored-by: MrAlokTech <107493955+MrAlokTech@users.noreply.github.com>
Deploying classnotes with
|
| Latest commit: |
21de856
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://8e239378.classnotes.pages.dev |
| Branch Preview URL: | https://bolt-pre-index-search-129200.classnotes.pages.dev |
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
💡 What: Added
prepareSearchIndexwhich loops over the data source (pdfDatabase) exactly once upon load to assign pre-computed search strings, parsed date values, and "isNew" statuses directly onto the objects.🎯 Why: In
script.js,renderPDFs()andcreatePDFCard()are executed repeatedly (e.g. on every single keystroke during searching). Without pre-calculation, the app re-instantiated Date objects, rantoLocaleDateStringwhich invokes heavy globalization utilities, and mapped object properties throughtoLowerCase()potentially hundreds or thousands of times within milliseconds. This effectively blocked the main thread causing typing lag and slow renders.📊 Impact: Reduces CPU bottlenecking during searches exponentially, decreasing lag directly correlated with database size. String concatenation, case transformation, and date localization have been moved out of an$O(N)$ high-frequency loop and into an $O(N)$ execution path that runs only once at load.
🔬 Measurement: Verify by typing in the search bar. Frame drops during rapid keystrokes will be notably minimized. No behavioral changes exist. Validated via Playwright DOM tests simulating search index state.
PR created automatically by Jules for task 12920006388194962318 started by @MrAlokTech