perf(datagrid): capture the column layout once per Size All Columns to Fit - #2463
Merged
Merged
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Signed-off-by: Ngô Quốc Đạt <datlechin@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two data grid defects found while investigating #2446, neither of them the reported bug. #2446 itself is already fixed on
mainby #2455; this is the residue that fix did not cover.Size All Columns to Fit was quadratic in the column count
sizeAllColumnsToFitwrites one width per column, and everyNSTableColumn.widthwrite posts its owncolumnDidResizeNotificationsynchronously. Each one reaches the persistence half oftableViewColumnDidResize, which runsscheduleLayoutPersist()→captureColumnLayout(), and that walks every attached column. So the menu item costscolumns × columns: about 250,000 iterations on the 500-column result #2381 measured. #2455 made the constant worse by adding a full-body invalidation to the same re-entry.The loop now runs with
isRebuildingColumnsset, so the run persists once at the end instead of once per column. Nothing is lost: the loop already callsmarkColumnWidthUserSizedper column, so ownership is unaffected, andcolumnGeometryDidChange()sits ahead of that guard so the repaint #2455 added still happens. The flag is saved and restored rather than cleared, so a fit nested inside a rebuild leaves the rebuild's own suppression intact.The header's leading edge showed a resize cursor with no divider there
SortableHeaderView.isInResizeZonefiltered onresizingMaskalone and never asked whether the result presents the column.NSTableHeaderView.headerRect(ofColumn:)returns a zero rect for a hidden column, so its trailing edge is x = 0, andDataGridColumnPoolkeeps every user-hidden column and every surplus slot of a previously wider result attached withuserResizingMaskset. Each of those reported a divider at x = 0.The effect: run a 10-column query and then a 3-column one in the same tab, or just hide a column, and the leftmost 4 points of the header show the column-resize cursor over the row-number heading and swallow the clicks that land there. It also cost one
headerRect(ofColumn:)per attached column on every mouse-moved event, surplus slots included.presentsColumnis the question CLAUDE.md already names for "which columns is the user looking at" (#2381), and it is now asked here too.CHANGELOG
maincarried two entries for one fix: #2456 accidentally swept an uncommitted(#2446)line into its commit alongside #2455's own(#2449)entry. Merged into one, per the "two entries describing one change get merged" rule.Verified
verify.sh build: PASSverify.sh test SizeAllColumnsToFitTests SortableHeaderResizeZoneTests DataGridColumnGeometryRepaintTests TableViewCoordinatorLayoutTests SortableHeaderViewTests: PASS, 62 executed, 62 passedverify.sh lint TablePro/Views/Results TableProTests/Views/Results: 0 violationstheLeadingEdgeIsNotAResizeZone,surplusPoolSlotsAreNotResizeZones,fittingEveryColumnCapturesOnce,captureCountIsIndependentOfColumnCount) and leaves the 7 guard tests green.No UI automation: neither defect has a deterministic XCUITest. The cursor one is a
NSCursorstate over a 4-point strip, and CI's accessibility tree does not expose header dividers; the perf one is a call count. Both are covered by unit tests that fail without the fix.No screenshots: neither change alters what the grid draws. The cursor fix changes which pointer appears over a 4-point strip of the header, which a screenshot does not capture.
Found while investigating #2446. That issue is fixed by #2455, not by this PR.
https://claude.ai/code/session_01MS7GCfhh6NmnPKajZ9wfpM