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
perf(nuxt): prefer iterating rather than Object.fromEntries
#24953
Conversation
Run & review this pull request in StackBlitz Codeflow. |
Sorry this took so long, personal life has been very demanding! |
Thanks for the refactor! |
May I ask why the revert? I get that smaller arrays would provide less of a performance improvement, but it's an improvement nonetheless. If anything, we can further improve performance in the small entry in vite as the input is known, so if we just create the object manually we avoid all function calls like map, like so: const toReplace = {
"X": "Y"
//...
}
//...
replace({...toReplace}) And I'm not even sure, could the bundles be considered small? Is it not user-input dependant? |
In the case of the analyse plugin, we are calling For the other one, it's also a one-time setup call called when Nuxt starts with a very small number of non-user controlled entries. Also negligible performance difference vs readability. |
Object.fromEntries
Object.fromEntries
Object.fromEntries
Well, in that case I suppose it's reasonable. Thanks for the feedback! |
π Linked issue
β Type of change
π Description
Many parts of nuxt require some sort of object manipulation, and therefore use Object.fromEntries and some more filter methods. This, especially in larger inputs, can really slow it down. This PR solves these issues by eliminating unnecessary iterations.
π Checklist