refactor: optimize getBaseProps with for-in loop and startsWith#4203
Open
TrevorBurnham wants to merge 1 commit intocloudscape-design:mainfrom
Open
refactor: optimize getBaseProps with for-in loop and startsWith#4203TrevorBurnham wants to merge 1 commit intocloudscape-design:mainfrom
TrevorBurnham wants to merge 1 commit intocloudscape-design:mainfrom
Conversation
georgylobko
reviewed
Jan 27, 2026
Member
georgylobko
left a comment
There was a problem hiding this comment.
@TrevorBurnham could you share your benchmark results?
Contributor
Author
Sure, I've shared a benchmark script and results here: https://gist.github.com/TrevorBurnham/4645e6cdddac26bad32d98971d359ddb |
georgylobko
approved these changes
Jan 28, 2026
Member
georgylobko
left a comment
There was a problem hiding this comment.
@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.
8a78ec2 to
c9ef3d6
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
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.
Description
This PR applies two micro-optimizations to
getBaseProps:Object.keys().forEach()with for-in loopString.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
CONTRIBUTING.md.CONTRIBUTING.md.Security
checkSafeUrlfunction.Testing
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.