Go Struct Field Reordering Optimization
Rewriting the first struct into the second (reordering fields) can improve performance and reduce memory usage due to better alignment:
type BadStruct struct { |
Reason: Group smaller fields together to minimize padding inserted by the compiler for alignment.
All articles on this blog are licensed under CC BY-NC-SA 4.0 unless otherwise stated.
Comments