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

Make the error size smaller #1603

Open
notgull opened this issue Jun 7, 2023 · 2 comments
Open

Make the error size smaller #1603

notgull opened this issue Jun 7, 2023 · 2 comments
Labels

Comments

@notgull
Copy link
Member

notgull commented Jun 7, 2023

The Error struct is six words wide. In comparison, most of the types returned via Result are one or two words wide. This means that there is about four words of space wasted in every Result. This could be fixed by making the Error type smaller, perhaps by Boxing its innards.

@kchibisov
Copy link
Member

I'm not sure from where you've got the fact that it's usually 2 words, if simple String is already 3 words, so with discriminant it'll be 4....

@kchibisov kchibisov added the api label Jun 7, 2023
@mattfbacon
Copy link

mattfbacon commented Jun 26, 2023

so with discriminant it'll be 4....

Not necessarily, because String is niched so for example Result<String, ()> is the same size as String. This works as long as E is one word or less, so Box fits perfectly (assuming thin pointer of course).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

3 participants