caching result of reading storage variable to save gas (#4535)

This commit is contained in:
Molly
2023-08-25 13:49:34 -04:00
committed by GitHub
parent 98203a72a6
commit b2e7bab920

View File

@ -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;