Skip to content

perf: cache selectedTabIndex + @ObservationIgnored on internal caches#529

Merged
datlechin merged 1 commit intomainfrom
perf/cache-selected-tab-index
Mar 31, 2026
Merged

perf: cache selectedTabIndex + @ObservationIgnored on internal caches#529
datlechin merged 1 commit intomainfrom
perf/cache-selected-tab-index

Conversation

@datlechin
Copy link
Copy Markdown
Collaborator

Summary

  • selectedTabIndex and selectedTab were O(n) computed properties scanning the tabs array via first { }. Called 160+ times per body evaluation cycle across 24 files (binding setters, coordinator extensions, view bodies). With 20+ tabs, this accumulated into measurable lag during column resize and sort.
  • Replaced with a lazy [UUID: Int] dictionary lookup, rebuilt only when the tabs array mutates via didSet. Amortizes the scan to once per mutation instead of once per access.
  • Marked querySortCache and isSwitchingDatabase as @ObservationIgnored on MainContentCoordinator — both are internal state never read from views, but were broadcasting change notifications on every write.

Test plan

  • Open 10+ tabs, switch between them — no regression
  • Open a table with 20+ columns, rapidly resize columns — should feel snappier
  • Sort a large query result (1000+ rows) — verify sort still works
  • Switch databases — verify no regression

@datlechin datlechin merged commit 76da4fd into main Mar 31, 2026
2 checks passed
@datlechin datlechin deleted the perf/cache-selected-tab-index branch March 31, 2026 07:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant