Skip to content

Conversation

@TrevorBurnham
Copy link
Contributor

@TrevorBurnham TrevorBurnham commented Jan 25, 2026

Description

This PR applies two micro-optimizations to getBaseProps:

  • Replace Object.keys().forEach() with for-in loop
  • Replace regex match with String.prototype.startsWith()

My benchmarks show a ~2.5x performance improvement. This function is called on every component render, so small optimizations here add up.

How has this been tested?

Existing tests provide extensive coverage for this functionality.

Review checklist

The following items are to be evaluated by the author(s) and the reviewer(s).

Correctness

  • Changes include appropriate documentation updates.
  • Changes are backward-compatible if not indicated, see CONTRIBUTING.md.
  • Changes do not include unsupported browser features, see CONTRIBUTING.md.
  • Changes were manually tested for accessibility, see accessibility guidelines.

Security

Testing

  • Changes are covered with new/existing unit tests?
  • Changes are covered with new/existing integration tests?

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@TrevorBurnham TrevorBurnham requested a review from a team as a code owner January 25, 2026 13:19
@TrevorBurnham TrevorBurnham requested review from georgylobko and removed request for a team January 25, 2026 13:19
Copy link
Member

@georgylobko georgylobko left a comment

Choose a reason for hiding this comment

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

@TrevorBurnham could you share your benchmark results?

@TrevorBurnham
Copy link
Contributor Author

@TrevorBurnham could you share your benchmark results?

Sure, I've shared a benchmark script and results here: https://gist.github.com/TrevorBurnham/4645e6cdddac26bad32d98971d359ddb

Copy link
Member

@georgylobko georgylobko left a comment

Choose a reason for hiding this comment

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

@TrevorBurnham thanks for sharing. LGTM!

Replace Object.keys().forEach() with for-in loop and regex match with
String.prototype.startsWith() for ~4x performance improvement.

This function is called on every component render, so the optimization
has a multiplicative effect across the library.
@georgylobko georgylobko force-pushed the perf/optimize-getbaseprops branch from 8a78ec2 to c9ef3d6 Compare January 28, 2026 13:18
@georgylobko georgylobko enabled auto-merge January 28, 2026 13:25
@codecov
Copy link

codecov bot commented Jan 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.17%. Comparing base (b9b1274) to head (c9ef3d6).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4203   +/-   ##
=======================================
  Coverage   97.17%   97.17%           
=======================================
  Files         882      882           
  Lines       25826    25826           
  Branches     9331     9331           
=======================================
  Hits        25097    25097           
  Misses        723      723           
  Partials        6        6           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 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.

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.

2 participants