Skip to content

Latest commit

 

History

History
29 lines (24 loc) · 1.51 KB

Storage Packing.md

File metadata and controls

29 lines (24 loc) · 1.51 KB

Storage Layout Packing: For each state variable, a size in bytes is determined according to its type.

Multiple, contiguous items that need less than 32 bytes are packed into a single storage slot if possible, according to the following rules:

  1. The first item in a storage slot is stored lower-order aligned

  2. Value types use only as many bytes as are necessary to store them

  3. If a value type does not fit the remaining part of a storage slot, it is stored in the next storage slot


Slide Screenshot

116.jpg


Slide Text

  • State Variables
  • Type -> Size in Bytes
  • Contiguous & Size Fits
    • Same Storage Slot
  • Contiguous & Not Fit
    • Next Storage Slot
  • First Item -> Lower-order Aligned

References


Tags

Storage, Stack Memory, Storage, and Flow Operations, Storage Layout, Storage Packing, Storage Layout & Ordering, [Storage Layout & Inheritance], Storage Layout for Mappings & Dynamic Arrays, State Variables, State Variables