29 May
2006
29 May
'06
8:28 p.m.
Daniel Mitchell schrieb:
Is constructing/passing a struct with no data members more efficient than it is with an enum, or is there no difference?
I don't know, but I would bet that the difference--it it exists at all--is negligible. Ideally the compiler will elide the struct/enum object altogether, since it's only the type that's important.
Yeah, shortly after my post I realized that optimizing away the value is quite trivially achieved - if the function is inlined, the value is dead anyway, if it isn't, the compiler might still find out by interprocedural analysis. Thanks a lot!