TIL that field order in structs matter
by @0xi4o
Here's an org struct:
Note the `struct with 88 pointer bytes could be 72` linter warning. If I change the order of the fields in the struct to this:
the warning goes away. From what I can tell, the lint rule called `fieldalignment` checks if the fields in a struct are ordered in an optimal way. What is the optimal way? Short version is all pointers should come first. I've never seen this before so it's something I'm interested in learning more about.
Note the `struct with 88 pointer bytes could be 72` linter warning. If I change the order of the fields in the struct to this:
the warning goes away. From what I can tell, the lint rule called `fieldalignment` checks if the fields in a struct are ordered in an optimal way. What is the optimal way? Short version is all pointers should come first. I've never seen this before so it's something I'm interested in learning more about.