-
Notifications
You must be signed in to change notification settings - Fork 12.4k
Open
Labels
Description
Opening issue as mentioned in #4576 (comment)
📝 Details
Since InitializableStorage is a struct with two fields packed in one storage slot, compiler need to load this slot when writing new value only for one of the fields, like here:
openzeppelin-contracts/contracts/proxy/utils/Initializable.sol
Lines 127 to 130 in 175b1e9
| if (isTopLevelCall) { | |
| $._initializing = false; | |
| emit Initialized(1); | |
| } |
Since (when) we know values for other fields, explicit usage of known values can let the compiler to prevent excessive SLOADs before SSTORE. Example:
$._initialized = 1;
$._initializing = false;PS: this is applicable not only in this place, but also in some other contracts.