Commit 9434d86
authored
Fix O(N²) mount/unmount scans in Session.patch_control (#6651)
* Fix O(N²) mount/unmount scans in Session.patch_control
patch_control checked every removed control against all added controls
(and vice versa) with linear any() scans, making each patch O(N²) in the
number of added/removed controls. When a @ft.component re-renders, the
frozen diff reports every matched control as both removed and re-added,
so components rendering large lists pay this cost on every re-render,
blocking the asyncio event loop for the duration.
Precompute added/removed ID sets once so each membership check is O(1),
reducing the whole function to O(N). Behaviour is unchanged:
will_unmount/did_mount still fire only for controls not present in both
sets, and index management, logging, and message sending are untouched.
* Updating CHANGELOG.md for #66511 parent f259b95 commit 9434d86
2 files changed
Lines changed: 5 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| 72 | + | |
72 | 73 | | |
73 | 74 | | |
74 | 75 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
247 | 247 | | |
248 | 248 | | |
249 | 249 | | |
| 250 | + | |
250 | 251 | | |
251 | | - | |
| 252 | + | |
252 | 253 | | |
253 | 254 | | |
254 | 255 | | |
| |||
264 | 265 | | |
265 | 266 | | |
266 | 267 | | |
| 268 | + | |
267 | 269 | | |
268 | 270 | | |
269 | | - | |
| 271 | + | |
270 | 272 | | |
271 | 273 | | |
272 | 274 | | |
| |||
0 commit comments