⚡ Bolt: [performance improvement]#82
Conversation
Changed `CartSummary` to a `data class` to use structural equality rather than reference equality. This prevents `CartBanner` from undergoing unnecessary recompositions when parent states like `refreshCount` change. Also updated Dejavu tests in `RecompositionRegressionTest` to use the fixed assertions properly. Co-authored-by: himattm <6266621+himattm@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. |
There was a problem hiding this comment.
Code Review
This pull request converts the CartSummary class to a data class to resolve recomposition regressions in Compose by enabling structural equality checks. The changes include updates to the regression tests to assert stability and exact recomposition counts, as well as a new entry in the learning log. Feedback was provided regarding stale documentation in ProductList.kt that still describes the class as unstable and should be updated to reflect the current implementation.
| // causing recomposition even when the logical content is the same. | ||
| // Making this a `data class` would fix the problem. | ||
| class CartSummary(val itemCount: Int, val totalPrice: String) | ||
| data class CartSummary(val itemCount: Int, val totalPrice: String) |
There was a problem hiding this comment.
The documentation preceding this class (lines 46-48 and the block at 34-44) is now stale as it describes CartSummary as an unstable regular class and suggests changing it to a data class as a fix. Since this change has been implemented, these comments should be updated or removed to accurately reflect the current code state and avoid confusing future maintainers.
💡 What: Changed
CartSummaryto a data class to enable structural equality instead of reference equality.🎯 Why: To prevent unnecessary recompositions of the
CartBannercomponent on unrelated state changes in its parentProductListScreen.📊 Impact: Eliminates wasted recompositions for
CartBannerduring interactions like refreshes, saving on UI invalidation cost.🔬 Measurement: Validated via Dejavu assertions in
RecompositionRegressionTest(assertStable()vsassertRecompositions(atLeast = 1)and similar cases).PR created automatically by Jules for task 13269919021934998792 started by @himattm