Skip to content

Optimize classnames and renderValue - #3992

Merged
nstepien merged 2 commits into
mainfrom
optclrv
Mar 6, 2026
Merged

nstepien merged 2 commits into
mainfrom
optclrv

Conversation

@nstepien

@nstepien nstepien commented Mar 6, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

@nstepien nstepien self-assigned this Mar 6, 2026
@codecov-commenter

codecov-commenter commented Mar 6, 2026 •

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.51%. Comparing base (bd32184) to head (2ce76c5).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3992      +/-   ##
==========================================
- Coverage   97.52%   97.51%   -0.02%     
==========================================
  Files          36       36              
  Lines        1456     1449       -7     
  Branches      466      463       -3     
==========================================
- Hits         1420     1413       -7     
  Misses         36       36              
Files with missing lines Coverage Δ
src/Cell.tsx 100.00% <ø> (ø)
src/DataGrid.tsx 98.96% <100.00%> (+<0.01%) ⬆️
src/HeaderCell.tsx 95.77% <ø> (-0.18%) ⬇️
src/cellRenderers/renderValue.tsx 100.00% <100.00%> (ø)
src/utils/styleUtils.ts 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

} catch {
return null;
}
return props.row?.[props.column.key as keyof R] as React.ReactNode;

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added ?. to remove try/catch, which may improve performance.
When would this throw an error?
Maybe if it's a get accessor that throws an error? 🤔

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be okay. Otherwise we are silently ignoring errors

Comment thread src/utils/styleUtils.ts
}

type ClassValue = Maybe<string> | Record<string, boolean> | false;
type ClassValue = Maybe<string | false>;

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove object support: fewer object allocations, -1 object type check, -1 loop, fewer object property access.

Comment thread src/utils/styleUtils.ts
}

return classname.trimStart();
return classname.slice(1);

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We know how much needs to be trimmed, and it works with empty strings as well, so we can skip the underlying trimStart() algo.

@nstepien
nstepien marked this pull request as ready for review March 6, 2026 16:56
@nstepien
nstepien requested a review from amanmahajan7 as a code owner March 6, 2026 16:56
} catch {
return null;
}
return props.row?.[props.column.key as keyof R] as React.ReactNode;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be okay. Otherwise we are silently ignoring errors

@nstepien
nstepien enabled auto-merge (squash) March 6, 2026 17:48
@nstepien
nstepien merged commit e533510 into main Mar 6, 2026
1 check passed
@nstepien
nstepien deleted the optclrv branch March 6, 2026 17:51
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.

3 participants