Skip to content

⚡ Bolt: Optimize time formatting, session calculations & UI state stability - #1

Merged
felixbrucker merged 1 commit into
mainfrom
bolt/optimize-performance-14466573189984143133
Sep 18, 2026
Merged

felixbrucker merged 1 commit into
mainfrom
bolt/optimize-performance-14466573189984143133

Conversation

@felixbrucker

Copy link
Copy Markdown
Owner

💡 What: Cached DateTimeFormatter instances as private constants in TimeExtensions.kt, decoupled session list aggregate statistics from the 1-second live duration ticker flow in SleepViewModel.kt, and annotated SleepTrackerUiState with @immutable.

🎯 Why: DateTimeFormatter.ofPattern was allocating new formatter objects on every time format call during UI rendering; combine in SleepViewModel was recomputing sumOf across all sleep sessions every second; and Compose compiler inferred SleepTrackerUiState as unstable due to List, causing unnecessary recompositions.

📊 Impact: Prevents repeated object allocations per second, reduces O(N) list loops on timer ticks during active sleep tracking, and enables Compose recomposition skipping for SleepTrackerScreen components.

🔬 Measurement: Verified with unit tests (./gradlew test) and lint checks (./gradlew lint).


PR created automatically by Jules for task 14466573189984143133 started by @felixbrucker

…bility

- Cache DateTimeFormatter instances in TimeExtensions.kt to eliminate repeated allocations.
- Decouple session list aggregate stats in SleepViewModel into a separate mapped flow to avoid O(N) recalculations on 1s live duration timer ticks.
- Annotate SleepTrackerUiState with @immutable to enable Compose recomposition skipping.

Co-authored-by: felixbrucker <5189997+felixbrucker@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown

👋 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.

@github-actions

Copy link
Copy Markdown

Coverage Report

Overall Project 44.33% -1.27% ❌
Files changed 53.54% ❌

File Coverage
TimeExtensions.kt 84.3% 🍏
SleepViewModel.kt 12.19% -4.63% ❌

@felixbrucker
felixbrucker merged commit d155d5f into main Sep 18, 2026
2 checks passed
@felixbrucker
felixbrucker deleted the bolt/optimize-performance-14466573189984143133 branch September 21, 2026 19:44
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