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

Precache, avoid cache-checking boolean values, and avoid unnecessary spreads #1021

Closed
wants to merge 1 commit into from

Conversation

tmcw
Copy link
Contributor

@tmcw tmcw commented Mar 17, 2022

Combination of two things that I could find that caused significant performance bumps for my benchmark:

  • This optimizes the cache for literals. true, false, null, and undefined are always going to be equal to each other: we might as well fill the cache with them and when they're returned, avoid the cacheAndReturn logic.
  • In hot code, using ... is causing performance drag because, in the current setup, zod's distributed files are using TypeScript helpers. This I'll file another PR for: my suspicion is that a very large portion of zod's performance problems are caused by that.

@tmcw tmcw mentioned this pull request Mar 17, 2022
@tmcw
Copy link
Contributor Author

tmcw commented Mar 17, 2022

I think removing the typeCache is a better solution than this one for primitives, and switching to es2018 is a better solution than avoiding spread syntax (for now).

@tmcw tmcw closed this Mar 17, 2022
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.

1 participant