⚡ Bolt: Optimize FirstAidRepository search and database seeding#95
⚡ Bolt: Optimize FirstAidRepository search and database seeding#95NITISH-R-G wants to merge 1 commit into
Conversation
- Introduce `_FirstAidEntry` to strongly type the corpus map. - Pre-compute `titleLower`, `tagsLower`, and `searchHaystackLower` strings when parsing the initial corpus JSON to avoid calling `.toLowerCase()` redundantly in search loops. - Use `appDb.executeBatch` instead of sequential `appDb.execute` calls inside a loop to insert corpus into SQLite, solving the N+1 query problem during database initialization. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
|
👋 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:
_FirstAidEntrymodel for the corpus that parses raw JSON once.titleLower,tagsLower,searchHaystackLower) within_FirstAidEntry.ensureInitialized()to useappDb.executeBatchfor SQLite initialization instead of repeatedly callingappDb.executein aforloop.🎯 Why:
.toLowerCase()and accessing string keys on dynamic maps (Map<String, dynamic>) inside high-frequency search and autocomplete loops (_lookupTokenScore,getSuggestions) is very inefficient, especially when scaling the corpus size.appDb.executequeries creates an N+1 performance bottleneck that blocks the UI and slows down first-launch or initialization.📊 Impact:
🔬 Measurement:
PR created automatically by Jules for task 966680841653860509 started by @NITISH-R-G