Skip to content

⚡ Bolt: Pre-calculate expensive derived properties for faster list rendering#43

Open
MrAlokTech wants to merge 1 commit intomainfrom
bolt-precalculate-search-index-1123171547595540183
Open

⚡ Bolt: Pre-calculate expensive derived properties for faster list rendering#43
MrAlokTech wants to merge 1 commit intomainfrom
bolt-precalculate-search-index-1123171547595540183

Conversation

@MrAlokTech
Copy link
Copy Markdown
Owner

💡 What: Added prepareSearchIndex to pre-calculate _searchStr, _formattedDate, and _isNew during data load. Refactored renderPDFs to use early returns and the pre-calculated search string. Updated createPDFCard to consume the pre-calculated variables.
🎯 Why: Instantiating Date objects and calling .toLowerCase() on multiple string fields during every keystroke and filter iteration caused excessive CPU overhead and sluggish search performance, especially as pdfDatabase grows.
📊 Impact: Significantly reduces CPU operations during the search filter loop by checking pre-compiled lowercase strings instead of repeatedly recomputing them. Prevents redundant Date object instantiations and formatting during rendering.
🔬 Measurement: Verified using a Playwright script by injecting mock data and asserting that cards are successfully filtered by the pre-calculated _searchStr when the user types in the search input. Tested frontend and confirmed zero visual or functional regressions.


PR created automatically by Jules for task 1123171547595540183 started by @MrAlokTech

Moves expensive operations (Date creation, string parsing, toLowerCase mapping)
out of the renderPDFs loop and into a one-time prepareSearchIndex step run on
data load. Also updates filtering logic to use early returns.

Co-authored-by: MrAlokTech <107493955+MrAlokTech@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying classnotes with  Cloudflare Pages  Cloudflare Pages

Latest commit: b81574e
Status: ✅  Deploy successful!
Preview URL: https://81c5e37f.classnotes.pages.dev
Branch Preview URL: https://bolt-precalculate-search-ind-rduz.classnotes.pages.dev

View logs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant