Make the error size smaller
notgull opened this issue · 2 comments
notgull commented
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 Box
ing its innards.
kchibisov commented
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....
mattfbacon commented
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).