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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: use Maps rather than objects as cache holders #9902

Merged
merged 5 commits into from Apr 28, 2020

Conversation

SimenB
Copy link
Member

@SimenB SimenB commented Apr 27, 2020

Summary

Maps are about twice as fast for larger data sets in Chrome 80, very much likely this applies to Node as well: https://stackoverflow.com/a/55711780/1850276

Similar to #8232, but applied to all caches.

(Includes #9900 as I forgot to switch to master first and can't be bothered to fix the conflict twice 馃榾 Please review second commit until I rebase)

Test plan

Green CI.

type StringMap = Map<string, string>;
type BooleanMap = Map<string, boolean>;

const fromEntries: typeof Object.fromEntries =
Copy link
Member Author

Choose a reason for hiding this comment

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

Object.fromEntries was added in node 12.

Can ditch this when jest-resolve uses a Map as well

Copy link
Collaborator

@thymikee thymikee left a comment

Choose a reason for hiding this comment

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

Yes please

this._moduleImplementation = undefined;

// @ts-ignore
this._config = undefined;
Copy link
Member Author

Choose a reason for hiding this comment

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

probably not needed, but doesn't hurt do help GC along

@SimenB
Copy link
Member Author

SimenB commented Apr 28, 2020

Ah, this of course breaks pretty hard when the user does something after teardown

@SimenB SimenB merged commit b4228da into jestjs:master Apr 28, 2020
@SimenB SimenB deleted the maps-over-objects branch April 28, 2020 14:55
@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants