Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve performance of mergeReactProps #456

Merged

Conversation

marcpachecog
Copy link
Contributor

The mergeReactProps function 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.

@mui-bot
Copy link

mui-bot commented Jun 12, 2024

Netlify deploy preview

https://deploy-preview-456--base-ui.netlify.app/

Generated by 🚫 dangerJS against 6325945

@atomiks
Copy link
Contributor

atomiks commented Jun 13, 2024

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?

@marcpachecog
Copy link
Contributor Author

marcpachecog commented Jun 13, 2024

@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

@michaldudak
Copy link
Member

Testing on my machine shows that the regex is ~30% slower on average, so IMO it is worth merging.

@atomiks
Copy link
Contributor

atomiks commented Jun 13, 2024

@marcpachecog ok seems fine to me then!

@atomiks atomiks merged commit fe2c0ba into mui:master Jun 14, 2024
18 of 19 checks passed
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.

5 participants