⚡ Bolt: Inline duration formatting to reduce heap allocations#92
⚡ Bolt: Inline duration formatting to reduce heap allocations#92juntaochi wants to merge 1 commit into
Conversation
- Inlined the calculation for duration display (minutes and seconds) directly into a single format string in `src/ui/mod.rs` `App::update`. - Removed `format_duration` and `format_duration_seconds` to avoid the overhead of multiple intermediate String heap allocations. - Documented in `.jules/bolt.md`.
|
👋 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:
Inlined the duration integer calculations (
minutes/seconds) directly into theformat!macros inside theApp::updatemetadata cache refresh block. Removed the helper functionsformat_durationandformat_duration_secondswhich were causing multiple redundant allocations.🎯 Why:
Previously, the TUI main update loop would call
format_duration, which allocated aString. ThatStringwas then immediately passed as an argument to anotherformat!macro, causing a secondary allocation. This pattern (nested format allocations) happened multiple times per metadata refresh in the hot path.📊 Impact:
Reduces heap memory allocations by ~66% (from 6
Stringallocations down to 2) during track metadata refreshes in the TUI's hot loop, reducing memory pressure.🔬 Measurement:
Run
cargo testandcargo check. The output string visually remains exactly the same as before (e.g.02:30 / 05:00and150s/300s | 50%). Tested UI logic via existing test suite.PR created automatically by Jules for task 6798792715619754304 started by @juntaochi