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

Fully remove typecache #1058

Merged
merged 2 commits into from
Mar 30, 2022
Merged

Conversation

tmcw
Copy link
Contributor

@tmcw tmcw commented Mar 30, 2022

The typecache was no longer used as of #1023 but we never fully removed it. So, an unnecessary Map was still being created per call to parse or safeParse. This removes that call.

Benchmarks: https://observablehq.com/d/b4b367792308cedb

Since this is a performance bump that just affects the top-level method, the impact on microtests is dramatic - like 20%+. For example, this code benefits dramatically:

const str = z.string();
str.parse('foo');

There probably aren't that many people who have such small zod schemas in prod, but nevertheless… it was wasted memory and time and now it isn't.

There's still a very large gap between zod & myzod for primitives which I've having a tough time bridging, still working on that.

@tmcw tmcw force-pushed the fully-remove-typecache branch 2 times, most recently from 7a2e2e3 to 8d900ff Compare March 30, 2022 14:47
@scotttrinh scotttrinh merged commit 0acd6f6 into colinhacks:master Mar 30, 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.

2 participants