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

Add cache for known plugins #301

Merged
merged 3 commits into from
Jun 29, 2024
Merged

Add cache for known plugins #301

merged 3 commits into from
Jun 29, 2024

Conversation

thecrypticace
Copy link
Contributor

We have to call require.resolve(…) ~10 times per call to parse(…). These calls generally take microseconds however if you call prettier.format(…) several thousand times the times add up. It also adds up for embedded documents which call parse(…) a large number of times.

This PR adds a cache for these calls because generally only a few will ever be installed and Node.js will not cache misses internally.

We have to call `require.resolve(…)` ~10 times per call to `parse(…)`. These calls generally take microseconds however if you call `prettier.format(…)` several thousand times the times add up. It also adds up for embedded documents which call `parse(…)` a large number of times.

This adds a cache for these calls because generally only a few will ever be installed and Node.js will not cache misses internally.
src/config.ts Show resolved Hide resolved
src/plugins.ts Outdated Show resolved Hide resolved
src/resolve.ts Show resolved Hide resolved
Co-authored-by: Robin Malfait <[email protected]>
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.

2 participants