Skip to content

⚡ Bolt: Inline duration formatting to reduce heap allocations#92

Open
juntaochi wants to merge 1 commit into
mainfrom
bolt-inline-duration-formatting-6798792715619754304
Open

⚡ Bolt: Inline duration formatting to reduce heap allocations#92
juntaochi wants to merge 1 commit into
mainfrom
bolt-inline-duration-formatting-6798792715619754304

Conversation

@juntaochi
Copy link
Copy Markdown
Owner

💡 What:
Inlined the duration integer calculations (minutes/seconds) directly into the format! macros inside the App::update metadata cache refresh block. Removed the helper functions format_duration and format_duration_seconds which were causing multiple redundant allocations.

🎯 Why:
Previously, the TUI main update loop would call format_duration, which allocated a String. That String was then immediately passed as an argument to another format! 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 String allocations down to 2) during track metadata refreshes in the TUI's hot loop, reducing memory pressure.

🔬 Measurement:
Run cargo test and cargo check. The output string visually remains exactly the same as before (e.g. 02:30 / 05:00 and 150s/300s | 50% ). Tested UI logic via existing test suite.


PR created automatically by Jules for task 6798792715619754304 started by @juntaochi

- 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`.
@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.

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