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

Optimize layout of nested field-less enums #53669

Closed
newpavlov opened this issue Aug 24, 2018 · 2 comments
Closed

Optimize layout of nested field-less enums #53669

newpavlov opened this issue Aug 24, 2018 · 2 comments

Comments

@newpavlov
Copy link
Contributor

pub enum Bar {
    A = 1,
    B = 2,
    C = 3,
}

pub enum Baz {
    D = 4,
    E = 5,
    F = 6,
}

pub enum Foo {
    Bar(Bar),
    Baz(Baz),
}

Currently Foo takes 2 bytes, even though it can be trivially represented as a single u8.

@leoschwarz
Copy link

I think this is related to #46213, which is as far as I understand a more general case of your proposed optimization.

@newpavlov
Copy link
Contributor Author

Hm, looks like it. I will close this issue in favor of the linked one.

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

No branches or pull requests

2 participants