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

Decrease Unit implementation runtime size #360

Merged
merged 1 commit into from
Apr 23, 2022
Merged

Conversation

chriskrycho
Copy link
Collaborator

Make it a prototype-less object which is cast as Unit. This means that it has an even smaller overhead at runtime than it did before, and it basically acts like an empty object in the type system... but one with a useful name, and a guarantee that there is only ever one of it.

All the type test changes here indicate that this is a wider type, usable in more places than previously. Since it was impossible to perform an actual brand check before in a way that surfaced in the type system, this is safe. (From a runtime POV, users could have been distinguishing it by using Object.getOwnPropertySymbols() but 🤷🏼‍♂️)

Make it a prototype-less object which is *cast* as `Unit`. This means
that it has an even smaller overhead at runtime than it did before, and
it basically acts like an empty object in the type system... but one
with a useful name, and a guarantee that there is only ever one of it.
@chriskrycho chriskrycho merged commit 2485712 into main Apr 23, 2022
@chriskrycho chriskrycho deleted the slightly-simpler-unit branch April 23, 2022 04:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant