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

Use an u8 for the tag of enums with up to 255 constructors #807

Open
yorickpeterse opened this issue Jan 30, 2025 · 0 comments
Open

Use an u8 for the tag of enums with up to 255 constructors #807

yorickpeterse opened this issue Jan 30, 2025 · 0 comments
Labels
compiler Changes related to the compiler feature New things to add to Inko, such as a new standard library module performance Changes related to improving performance

Comments

@yorickpeterse
Copy link
Collaborator

Description

The tag of an enum is now a u16, regardless of how many constructors there are. Most enums will have less than 255 constructors such that we can use a u8 instead in those cases. This in turn can be beneficial when storing an enum into another type, as depending on the order/padding of fields this can conserve space. One example is the FutureState type (see also #806).

We should change the compiler such that tags are lowered to a u8 if the enum has at most 255 constructors.

Related work

No response

@yorickpeterse yorickpeterse added compiler Changes related to the compiler feature New things to add to Inko, such as a new standard library module performance Changes related to improving performance labels Jan 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler Changes related to the compiler feature New things to add to Inko, such as a new standard library module performance Changes related to improving performance
Projects
None yet
Development

No branches or pull requests

1 participant