Repository navigation
⚡ Bolt: Optimize time formatting, session calculations & UI state stability - #1
Conversation
…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>
|
👋 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. |
Coverage Report
|
💡 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