⚡ Bolt: Optimize compareTo with zero-allocation parser#809
⚡ Bolt: Optimize compareTo with zero-allocation parser#809google-labs-jules[bot] wants to merge 1 commit intomainfrom
Conversation
Replaces the regex and split-based version parser with a single-pass `charCodeAt` parser.
- Avoids array allocation from `split('.')`
- Avoids string allocation from `replace()` and `trim()`
- Avoids RegExp overhead
- Maintains strict validation parity (rejects whitespace, invalid chars)
Benchmark: ~13x speedup (3723ms -> 285ms for 1M iterations)
|
👋 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. |
|
|
Important Review skippedBot user detected. To trigger a single review, invoke the You can disable this status message by setting the Comment |
|
Superseded by #826 - closing duplicate bot-generated PR |
⚡ Bolt Optimization:
compareToZero-Allocation Parser💡 What: Refactored
compareToto use a manual character-by-character parser instead ofsplit,replace, andRegExp.🎯 Why: Version comparison is a hot path. The previous implementation allocated multiple strings and arrays for every comparison, creating garbage collection pressure.
📊 Impact:
🔬 Measurement:
bench.ts(1M iterations over 7 version strings).bun run test).PR created automatically by Jules for task 11172138652610001456 started by @srod
Summary by cubic
Rewrote compareTo to a zero-allocation, single-pass parser to remove regex/split overhead and cut GC pressure. Delivers ~13x speedup in benchmarks (3723ms -> 285ms for 1M calls) with the same comparison behavior.
Written for commit 9c0b23d. Summary will update on new commits.