sidebar: Improve performance of `rebuild_contents` (#57717)

Release Notes:

- N/A or Added/Fixed/Improved ...
6555ac3d04Lukas Wirth committed on 5/27/2026, 10:31:57 AM· committed by GitHubparent75c17a6
9 files changedLine totals unavailable