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 a type-checking fast path for primitive types #755

Merged
merged 1 commit into from Mar 17, 2021
Merged

Add a type-checking fast path for primitive types #755

merged 1 commit into from Mar 17, 2021

Conversation

amcasey
Copy link
Contributor

@amcasey amcasey commented Feb 19, 2021

When Draft<T> is applied to a large enum type, TypeScript has to do a lot of unnecessary structural comparisons to confirm that no element of the enum matches Function, Date, RegExp, etc. Determining that they do match string or number, on the other hand, is trivial. This change splits PrimitiveType out of AtomicObject so that the fast path can be checked first.

In microsoft/TypeScript#42824, this cut the check time from ~2.5 seconds to ~0.3 seconds.

When `Draft<T>` is applied to a large enum type, TypeScript has to do a
lot of unnecessary structural comparisons to confirm that no element of
the enum matches `Function`, `Date`, `RegExp`, etc.  Determining that
they do match `string` or `number`, on the other hand, is trivial.  This
change splits `PrimitiveType` out of `AtomicObject` so that the fast
path can be checked first.

In microsoft/TypeScript#42824, this cut the
check time from ~2.5 seconds to ~0.3 seconds.
@amcasey
Copy link
Contributor Author

amcasey commented Feb 19, 2021

Supersedes #754.

@mweststrate mweststrate merged commit d395efe into immerjs:master Mar 17, 2021
@mweststrate
Copy link
Collaborator

Merged, thanks!

@mweststrate
Copy link
Collaborator

🎉 This PR is included in version 8.0.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

@amcasey amcasey deleted the AtomicObject branch March 17, 2021 16:35
This was referenced Mar 18, 2021
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