Commit 251d9db
⚡ Bolt: Cache pointsByIndex in ChartData
💡 What: Added `pointsByIndexMap` to the `ChartData` class to precompute and cache the grouped and sorted points by index.
🎯 Why: The `groupBy { it.first }.toSortedMap()` operation was being redundantly executed on every touch event within `onTap`, causing unnecessary allocations and processing.
📊 Impact: Replaced O(N log N) sorting and grouping on every tap with an O(1) map lookup, reducing CPU overhead and allocation churn during user interaction.
🔬 Measurement: A microbenchmark showed a 99.8% execution time reduction (from 131.4ms to 0.25ms over 10k iterations) when accessing precomputed groupings compared to redundant grouping and sorting.
Co-authored-by: alvin000009238 <107313913+alvin000009238@users.noreply.github.com>1 parent fd03a1f commit 251d9db
3 files changed
Lines changed: 506 additions & 3 deletions
File tree
- .jules
- android/app/src/main/java/com/clhs/score/ui
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
Lines changed: 6 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
| 48 | + | |
| 49 | + | |
49 | 50 | | |
50 | 51 | | |
51 | 52 | | |
| |||
111 | 112 | | |
112 | 113 | | |
113 | 114 | | |
| 115 | + | |
114 | 116 | | |
115 | 117 | | |
116 | 118 | | |
| |||
128 | 130 | | |
129 | 131 | | |
130 | 132 | | |
| 133 | + | |
131 | 134 | | |
132 | 135 | | |
133 | 136 | | |
| |||
153 | 156 | | |
154 | 157 | | |
155 | 158 | | |
156 | | - | |
| 159 | + | |
157 | 160 | | |
158 | 161 | | |
159 | 162 | | |
| |||
213 | 216 | | |
214 | 217 | | |
215 | 218 | | |
216 | | - | |
| 219 | + | |
217 | 220 | | |
218 | 221 | | |
219 | 222 | | |
| |||
0 commit comments