Skip to content

Commit 1bd6a53

Browse files
committed
fix colulmn sizing test
1 parent 0d1f3cf commit 1bd6a53

2 files changed

Lines changed: 19 additions & 12 deletions

File tree

packages/table-core/tests/unit/features/column-resizing/columnResizingFeature.utils.test.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,13 +435,20 @@ describe('passiveEventSupported', () => {
435435
expect(firstResult).toBe(secondResult)
436436
})
437437

438-
it('should handle errors during support check', () => {
438+
it('should handle errors during support check', async () => {
439+
// Reset modules so passiveEventSupported's cache starts fresh —
440+
// earlier tests in this describe block populate the module-level cache,
441+
// which would otherwise short-circuit before reaching the throwing spy.
442+
vi.resetModules()
443+
const { passiveEventSupported: freshPassiveEventSupported } =
444+
await import('../../../../src/features/column-resizing/columnResizingFeature.utils')
445+
439446
const addEventListenerSpy = vi.spyOn(window, 'addEventListener')
440447
addEventListenerSpy.mockImplementation(() => {
441448
throw new Error('Test error')
442449
})
443450

444-
const result = passiveEventSupported()
451+
const result = freshPassiveEventSupported()
445452
expect(result).toBe(false)
446453

447454
addEventListenerSpy.mockRestore()

perf.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ Typecheck verified clean after the sweep (`pnpm tsc --noEmit` passes).
9696
- **Total findings:** 60
9797
- **Done `[x]`:** 17
9898
- **Partial `[~]`:** 2
99-
- **Skipped `[-]`:** 1
100-
- **Not started `[ ]`:** 40
99+
- **Skipped `[-]`:** 5
100+
- **Not started `[ ]`:** 36
101101

102102
_(Update these counters as you go.)_
103103

@@ -929,8 +929,8 @@ for (let i = 0; i < flatRows.length; i++) {
929929

930930
## 24. `column_getFilterValue` / `column_getFilterIndex` linear `.find` — Score: 6
931931

932-
**Status:** `[ ]` not started
933-
**Implementation note:** _(none)_
932+
**Status:** `[-]` skipped
933+
**Implementation note:** Per project guidance, `columnFilters` state typically holds 1–3 active filters. At that size, `.find` over the array is essentially O(1) in practice and outperforms a Record/Map lookup (no hashing, no per-rebuild allocation, JIT-friendly). The C × F scale-impact math assumes F grows with C, but in real tables F stays small even when C is large — so the multiplier shown in the table overstates the win. Both alternatives (per-column memo, `table.getColumnFiltersById()`) add overhead that isn't recouped at typical filter counts.
934934

935935
**Location:** `src/features/column-filtering/columnFilteringFeature.utils.ts:156–185`
936936
**Category:** `big-o`, `memoization`
@@ -1092,8 +1092,8 @@ Skip the `row.columnFilters = {}` write when it's already an empty object.
10921092

10931093
## 30. `existingGrouping.includes(colId)` per cell value access — Score: 7
10941094

1095-
**Status:** `[ ]` not started
1096-
**Implementation note:** _(none)_
1095+
**Status:** `[-]` skipped
1096+
**Implementation note:** Per project guidance, `grouping` state typically holds 1–3 columns. At that size, `.includes()` on the array is ~2–3 reference comparisons — cheaper than a Set lookup (hash + bucket walk + comparison), and avoids the per-row-model-rebuild Set allocation. The G × C × R scale table assumes G grows; in real grouped tables G is bounded and small, so the constant-factor Set overhead would dominate the saved comparisons. See [[skip-policy-small-state-arrays]] for the project-wide rule.
10971097

10981098
**Location:** `src/features/column-grouping/createGroupedRowModel.ts:141–152`
10991099
**Category:** `big-o`
@@ -1200,8 +1200,8 @@ Inside the grouped row's `getValue`, every non-grouped column lookup calls `tabl
12001200

12011201
## 34. `orderColumns` uses `grouping.includes` — Score: 7
12021202

1203-
**Status:** `[ ]` not started
1204-
**Implementation note:** _(none)_
1203+
**Status:** `[-]` skipped
1204+
**Implementation note:** Per project guidance, `grouping` state typically holds 1–3 columns. The L × G scale-table line that shows `L × G` ballooning with L assumes G also grows, but G stays bounded in real tables — so the inner walk is essentially L × constant ≈ O(L), comparable to L + G once the per-call Set allocation and hashing overhead are factored in. Matches the same decision recorded in #39 for the pin-side partition. See [[skip-policy-small-state-arrays]].
12051205

12061206
**Location:** `src/features/column-ordering/columnOrderingFeature.utils.ts:205–225`
12071207
**Category:** `big-o`
@@ -1295,8 +1295,8 @@ for (let i = 0; i < left.length; i++) {
12951295

12961296
## 36. `[...left, ...right].includes(id)` for center column filtering — Score: 6
12971297

1298-
**Status:** `[ ]` not started
1299-
**Implementation note:** _(none)_
1298+
**Status:** `[-]` skipped
1299+
**Implementation note:** Per project guidance, `columnPinning` state (`left` + `right`) typically holds 1–3 ids per side. At that size, `.includes()` on the small arrays outperforms a Set (no hashing, no per-call allocation). Same reasoning as #39, which deliberately chose `.includes()` over Sets for the cell-side partition. Note: the per-call `[...left, ...right]` spread itself is wasted work and could be removed without converting to a Set — `(left.includes(id) || right.includes(id))` is the equivalent allocation-free check. Documenting that micro-fix here for any later pass that wants to pick it up; not pursuing it now since it doesn't change asymptotic behavior. See [[skip-policy-small-state-arrays]].
13001300

13011301
**Location:** `src/features/column-pinning/columnPinningFeature.utils.ts:189, 430`
13021302
**Category:** `big-o`

0 commit comments

Comments
 (0)