Repository navigation
Improve performance of mergeReactProps - #456
Merged
atomiks merged 1 commit intoJun 14, 2024
Merged
Conversation
marcpachecog
requested review from
atomiks,
colmtuite and
michaldudak
as code owners
June 12, 2024 15:53
Netlify deploy preview |
Contributor
|
Thank you for the PR! However it seems like they're practically identical in performance to the point that the bundle size cost would instead be the more impactful trade-off? |
Contributor
Author
|
@atomiks This can be true for high-end devices, especially in desktop environments (in my case, regex is about 20% slower). However, the drop in performance is much more noticeable on mobile devices. In a large app, this regex might be invoked hundreds or even thousands of times, making this optimization potentially worthwhile. 339237249-a0f67ad4-17b4-46ea-8166-ec07a6ef4ed2.mov |
Member
|
Testing on my machine shows that the regex is ~30% slower on average, so IMO it is worth merging. |
michaldudak
approved these changes
Jun 13, 2024
Contributor
|
@marcpachecog ok seems fine to me then! |
1 task done
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.
The
mergeReactPropsfunction uses a regex to identify event handlers and invoke them all. Since it is a low-level utility, I believe it should be optimized for performance, even at the expense of some readability.Just suggesting an alternative approach that doesn't rely on using a regex.