2 ms·
If I'm understanding this correctly - the JITer does the same thing automatically that we used to do manually in C. That is, place larger variables first inside
by chiph 12y ago
If I'm understanding this correctly - the JITer does the same thing automatically that we used to do manually in C. That is, place larger variables first inside our structs, so that unnecessary padding isn't added to achieve word alignment.
If order is otherwise unimportant to you (coding standard demanding alphabetic order, offsets that must match a layout provided by someone else, etc), you could do it yourself when creating your class/struct.
- matthewwarren 12y agoYeah that sounds right, basically the JITter is free to re-order as it want. The order you write the fields in your class (in a .cs file) enfore anything. If you really need a specific memory layout, you need to use a trick like the one in the article, or resort to LayoutKind Sequential[0]. [0] http://support.microsoft.com/kb/922785 http://support.microsoft.com/kb/922785