4 ms·
This is something the compiler can't optimize very well. For one thing, the spec requires that they appear in the given order. If this wasn't the case, a sign
by pcmonk 12y ago
This is something the compiler can't optimize very well. For one thing, the spec requires that they appear in the given order.
If this wasn't the case, a significant amount of code would break. I've seen a good bit of code where there's a struct A, and then struct B begins with the same fields as in struct A. This allows you to treat either of them as a struct A, a kind of polymorphism. The compiler doesn't know whether you're going to do that, so it can't arbitrarily rearrange the members of the structs.