Skip to content

Commit

Permalink
caching result of reading storage variable to save gas (#4535)
Browse files Browse the repository at this point in the history
  • Loading branch information
molly-ting authored Aug 25, 2023
1 parent 98203a7 commit b2e7bab
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion contracts/proxy/utils/Initializable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ abstract contract Initializable {
InitializableStorage storage $ = _getInitializableStorage();

bool isTopLevelCall = !$._initializing;
if (!(isTopLevelCall && $._initialized < 1) && !(address(this).code.length == 0 && $._initialized == 1)) {
uint64 initialized = $._initialized;
if (!(isTopLevelCall && initialized < 1) && !(address(this).code.length == 0 && initialized == 1)) {
revert AlreadyInitialized();
}
$._initialized = 1;
Expand Down

0 comments on commit b2e7bab

Please sign in to comment.