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

refactor: use Object.fromEntries to build rule config maps #1320

Merged
merged 1 commit into from Jan 3, 2023

Conversation

NotWoods
Copy link
Contributor

@NotWoods NotWoods commented Jan 3, 2023

This is a tiny change to use Object.fromEntries (supported in Node 12+) instead of a .reduce loop.

This improves performance a little by making it a O(n) instead of O(n^2) operation, since spreading the accumulator means creating a new object each iteration of the loop.

Copy link
Collaborator

@G-Rath G-Rath left a comment

Choose a reason for hiding this comment

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

Sure, though I don't think it's worth marking it as a performance improvement unless you can actually show a clear speedup, since this is only done the first time the module is required and is for a relatively low number of files (which is why I didn't do this change in the first place)

@NotWoods
Copy link
Contributor Author

NotWoods commented Jan 3, 2023

I pretty much only chose "perf" because I couldn't think of a better label :) Happy to switch to "refactor" or anything else

@G-Rath G-Rath changed the title perf: use fromEntries to build rule map refactor: use Object.fromEntries to build rule config maps Jan 3, 2023
@G-Rath G-Rath merged commit f3cb13b into jest-community:main Jan 3, 2023
@NotWoods NotWoods deleted the no-spread branch January 3, 2023 21:24
@github-actions
Copy link

github-actions bot commented Jan 6, 2023

🎉 This PR is included in version 27.2.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants