Repository navigation
⚡ Bolt: reuse Intl.Collator for installed mod sorting - #323
google-labs-jules[bot] wants to merge 1 commit into
Conversation
String.prototype.localeCompare(b, undefined, { sensitivity: "base" })
instantiates a new Intl.Collator on each invocation. Reusing
module-level Intl.Collator instances provides an ~45x speedup and eliminates
thousands of temporary object allocations during list sorting.
|
👋 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. |
⚡ Bolt Optimization: Reuse module-level
Intl.Collatorinstances inInstalledPage.tsx💡 What
Replaced per-comparison calls to
a.name.localeCompare(b.name, undefined, { sensitivity: "base" })anda.name.localeCompare(b.name)with reusable module-levelIntl.Collatorinstances (baseCollatorandexactCollator).🎯 Why
In V8/JavaScript engines, calling$N$ items, $O(N \log N)$ comparisons are executed, repeatedly allocating thousands of transient
String.prototype.localeComparewith an options object allocates a newIntl.Collatorinstance on every single comparison. In a mod list sort ofIntl.Collatorobjects, triggering garbage collection overhead and blocking the main thread.📊 Impact
Benchmark shows sorting 500 items over 50 iterations drops from ~1500 ms to ~33 ms (~45x speedup) while completely eliminating thousands of transient object allocations.
🔬 Measurement
Verified via comparative benchmark measuring execution time and allocation behavior before and after reusing
Intl.Collator. All frontend compilation checks (pnpm build) and 141 backend unit tests (cargo test) pass cleanly.PR created automatically by Jules for task 6311186706021213183 started by @TheDragonSoft