Commit 865ebe8
committed
⚡ Bolt: Memoize Sunburst color calculation
This commit optimizes the `Sunburst` visualization by memoizing the recursive color calculation.
Previously, `color(node)` would recursively visit all children to compute the average color. Since `color` is called for every rendered node (and recursively for their children), this resulted in O(N*visible_nodes) complexity, causing redundant traversals.
The optimization caches the computed color in `node.extra.computedSunburstColor`. This reduces the complexity to O(N) for the initial traversal and O(1) for subsequent lookups.
Benchmark results showed a reduction from ~0.65ms per call (amortized over 1000 calls) to ~0.00013ms per call, a massive speedup for repeated rendering or interaction.
Existing tests passed.
Reverted unintended package-lock.json changes.1 parent d9f4cde commit 865ebe8
1 file changed
+11
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
149 | 149 | | |
150 | 150 | | |
151 | 151 | | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
152 | 156 | | |
153 | 157 | | |
154 | 158 | | |
155 | 159 | | |
156 | 160 | | |
157 | 161 | | |
| 162 | + | |
158 | 163 | | |
159 | 164 | | |
160 | | - | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
161 | 169 | | |
162 | 170 | | |
163 | | - | |
164 | | - | |
| 171 | + | |
| 172 | + | |
165 | 173 | | |
166 | 174 | | |
167 | 175 | | |
| |||
0 commit comments